ADO recorset update works first time, but not second?! 
Author Message
 ADO recorset update works first time, but not second?!

I have a form with an ADO Recordset which is used as the datasource for a
TrueOLEDBGrid. The recordset contains 2 inner joins. I have made sure
that the PKs from all 3 tables are included in the columns. I have set the
"Unique Table" and "Unique Catalog" Properties of the Recordset
to point to the table that is to be updated.

I start the app, run the form and can edit as many rows as I want in the
grid, with each update occuring as one would expect.

I close the form.

I reopen the form and try to edit the value in a row. When the update is
attempted, I get an "Insufficient key column information for update..."
error???

The Recordset is declared as follows, at the top of the form module:

Public myRS as ADODB.Recordset

and is initialized and opened during the load event as follows:

set myRS = new ADODB.Recordset
myRS.CursorLocation = adUseClient
myRS.Open SQL, myConn, adOpenDynamic, adLockOptimistic, adCmdText
myRS.Properties("Unique Table") = myTable
myRS.Properties("Unique Catalog") = myConn.Properties("Current Catalog")

At the unload event, I close the recordset and set it to Nothing.

What's going on here? As best as I can tell, I am executing the same code on
the same data twice in a row, with different results. It's as if something
about
the recordset is not being initialized or is being left in some
indeterminate
state when the window is closed.

Bruce Ray



Mon, 19 Jul 2004 06:27:41 GMT
 ADO recorset update works first time, but not second?!

Hi,

Are you sure that the form is being unloaded and not just hidden?

Have you checked if the code is actually being run the second time that the
form opens?

----------------------
Jeremy Wiebe
Software Developer
Linnet Geomatics Inc.


Quote:
> I have a form with an ADO Recordset which is used as the datasource for a
> TrueOLEDBGrid. The recordset contains 2 inner joins. I have made sure
> that the PKs from all 3 tables are included in the columns. I have set the
> "Unique Table" and "Unique Catalog" Properties of the Recordset
> to point to the table that is to be updated.

> I start the app, run the form and can edit as many rows as I want in the
> grid, with each update occuring as one would expect.

> I close the form.

> I reopen the form and try to edit the value in a row. When the update is
> attempted, I get an "Insufficient key column information for update..."
> error???

> The Recordset is declared as follows, at the top of the form module:

> Public myRS as ADODB.Recordset

> and is initialized and opened during the load event as follows:

> set myRS = new ADODB.Recordset
> myRS.CursorLocation = adUseClient
> myRS.Open SQL, myConn, adOpenDynamic, adLockOptimistic, adCmdText
> myRS.Properties("Unique Table") = myTable
> myRS.Properties("Unique Catalog") = myConn.Properties("Current Catalog")

> At the unload event, I close the recordset and set it to Nothing.

> What's going on here? As best as I can tell, I am executing the same code
on
> the same data twice in a row, with different results. It's as if something
> about
> the recordset is not being initialized or is being left in some
> indeterminate
> state when the window is closed.

> Bruce Ray



Mon, 19 Jul 2004 06:48:21 GMT
 ADO recorset update works first time, but not second?!
Thanks...

I have set and detected a breakpoint in the unload event, so I
guess the form is unloaded. I have stepped through the code
and can see no difference in execution path from pass one to
pass two. I have examined myRS.* and can see no differences
from pass one to pass two, including all the .Properties.

Any other suggestions?

Bruce


Quote:
> Hi,

> Are you sure that the form is being unloaded and not just hidden?

> Have you checked if the code is actually being run the second time that
the
> form opens?

> ----------------------
> Jeremy Wiebe
> Software Developer
> Linnet Geomatics Inc.



> > I have a form with an ADO Recordset which is used as the datasource for
a
> > TrueOLEDBGrid. The recordset contains 2 inner joins. I have made sure
> > that the PKs from all 3 tables are included in the columns. I have set
the
> > "Unique Table" and "Unique Catalog" Properties of the Recordset
> > to point to the table that is to be updated.

> > I start the app, run the form and can edit as many rows as I want in the
> > grid, with each update occuring as one would expect.

> > I close the form.

> > I reopen the form and try to edit the value in a row. When the update is
> > attempted, I get an "Insufficient key column information for update..."
> > error???

> > The Recordset is declared as follows, at the top of the form module:

> > Public myRS as ADODB.Recordset

> > and is initialized and opened during the load event as follows:

> > set myRS = new ADODB.Recordset
> > myRS.CursorLocation = adUseClient
> > myRS.Open SQL, myConn, adOpenDynamic, adLockOptimistic, adCmdText
> > myRS.Properties("Unique Table") = myTable
> > myRS.Properties("Unique Catalog") = myConn.Properties("Current Catalog")

> > At the unload event, I close the recordset and set it to Nothing.

> > What's going on here? As best as I can tell, I am executing the same
code
> on
> > the same data twice in a row, with different results. It's as if
something
> > about
> > the recordset is not being initialized or is being left in some
> > indeterminate
> > state when the window is closed.

> > Bruce Ray



Mon, 19 Jul 2004 23:37:08 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Update of ado recordset works first time, not second

2. ADO Recordset not updating first time

3. First Time on Newsgroups a second time around!

4. is not working the pull method in the second time

5. NEWBIE - works first time but not 2nd or 3rd

6. Distributed Transaction Failing on First Try, Second Try Works

7. Obtain records from first query NOT in second?

8. Updates and xp_cmdshell not working all the time in DTS

9. Log Shipping almost works, monitor does not update, restore fails after 1 time

10. Query of two tables, Return the first if not in second

11. ADO 2.7 Timeout when selecting on a second connection with a Transaction pending on the first

12. ADO UPDATE method not working with a table trigger


 
Powered by phpBB® Forum Software