![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I'm trying to connect to an ADO recordset coming from a Pervasive 2000i database via ODBC, using VB6, and update two fields, but for some reason I'm not able to do the update. Below is what I hope is the relevant part of my code. The database connection seems to open and read records fine, but further down I (try to) assign the value of a variable to a field as follows -- "rst!BegAccumDepr = BegAccumDepr" and at that point the code errors out with the following message "Run-time error: '-2147352566 (8002000a)' Out of present range." The field I want to update does not actually exist in the database, I create that one and another at the end of the SELECT clause of my query: "SELECT field, field, field, 0 AS BegAccumDepr, 0 AS CurrentDepr" to use as a placeholder. Ultimately I need to use the updated recordset to run a Crystal report. Any help is appreciated. Robin ~~~~~~~~~ Set cnn = New ADODB.Connection Set rst = New ADODB.Recordset cnn.ConnectionString = "DSN=LP70Lease" cnn.Open rst.ActiveConnection = cnn rst.Open strSQL, cnn, adOpenKeyset, adLockOptimistic rst.MoveFirst ~~~~~~~~~~~~~~~~~ |
#3
| |||
| |||
|
|
Robin, the SQL AS clause creates an alias. It does not create a field. You have not created a field so you can not update it. ADO fails because there is no underlying field to update. If you want to create a field in the underlying table you can use ALTER TABLE [table name] ADD [field name] [column data type] [size]; |
#4
| |||
| |||
|
|
Thanks for your reply. I was suspecting that something like this was the case, but was hoping there was a way around it. If I can't make changes to the underlying table (which is actually a SELECT statement using 6-7 tables) can I create a place to store these additional "fields" by creating a view with my select statement and adding those two additional fields? If that won't work, and knowing I can't alter any tables, do I have any other options? Thanks again. Robin "Doug Bell" <dug@bigpond> wrote Robin, the SQL AS clause creates an alias. It does not create a field. You have not created a field so you can not update it. ADO fails because there is no underlying field to update. If you want to create a field in the underlying table you can use ALTER TABLE [table name] ADD [field name] [column data type] [size]; |
#5
| |||
| |||
|
|
Robin, I am not totally familiar with using views and Crystal but I think like in Access we can create a Query and then maybe Crystal can be run based on the results of that query rather than a table. |
#6
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |