ADO Persistance Problem 
Author Message
 ADO Persistance Problem

Hi,

    I am using Access 2000 Database.I have used ADO in my
Project. i am using the following code to store the data
into the table. But some times, the data insertion wast
successful. Its not Always. Can you please specify the
reason.

Thanks,

Chakri

    1) Method One

     private rsCustomer as ADODB.Recoredset

     set rsCustoemr = new ADODB.Recordset

     rsCustomer.open SQL,cnn,adOpenKeyset,adLockOptimistic

     rsCustomer.AddNew
     rsCustomer.Fields(0).value = somevalue
     rscustomer.Update

    2) Method 2

     SQLCompound = "INSERT INTO Customers values  
(somevalue)"

      cnn.Execute SQLCompound



Sat, 26 Nov 2005 18:03:27 GMT  
 ADO Persistance Problem
I'd probably prefer to use
rsCustomer.open SQL,cnn,adOpenDynamic,adLockOptimistic

The use of integer values to specify fields leads to future problems
when upgrading an application e.g.
rsCustomer.Fields(0).value = somevalue
The reason is at some future time you may add a new field to the
recordset and change the index order which will cause problems in your
code. I suggest it's best to refer to a field by it's name, then it
doesn't matter where it is in the index.
rsCustomer.Fields("FieldName").value = somevalue

Regards
Dave Ward

Quote:

> Hi,

>     I am using Access 2000 Database.I have used ADO in my
> Project. i am using the following code to store the data
> into the table. But some times, the data insertion wast
> successful. Its not Always. Can you please specify the
> reason.

> Thanks,

> Chakri

>     1) Method One

>      private rsCustomer as ADODB.Recoredset

>      set rsCustoemr = new ADODB.Recordset

>      rsCustomer.open SQL,cnn,adOpenKeyset,adLockOptimistic

>      rsCustomer.AddNew
>      rsCustomer.Fields(0).value = somevalue
>      rscustomer.Update

>     2) Method 2

>      SQLCompound = "INSERT INTO Customers values
> (somevalue)"

>       cnn.Execute SQLCompound



Sun, 27 Nov 2005 12:18:03 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ADO Persistance to XML

2. msmq and ado recordset persistance

3. msmq and ado recordset persistance

4. Problem with Persistance of object type between apps

5. ActiveX Exe Persistance problem

6. Persistance of objects

7. Custom complex properties persistance

8. Object Persistance/Serialization

9. .NET Persistance

10. Instancing and Persistance in classes

11. Object persistance

12. Saving the state (Persistance) of an ActiveX control in VB

 

 
Powered by phpBB® Forum Software