Re: Insert to Access DB with Autonumber field
From: Val Mazur (group51a_at_hotmail.com)
Date: 06/25/04
- Next message: Val Mazur: "Re: VBscript Error 800a01a8 on Connection.Close"
- Previous message: Douglas Laudenschlager [MS]: "Re: VC++ connect string for Excel 2002?"
- In reply to: Microsoft: "Insert to Access DB with Autonumber field"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 24 Jun 2004 21:47:06 -0400
Hi,
First of all why do you open the whole table to insert records? It is very
expensive and in a case of big table you will experience performance issues.
If you need to add something to the database, then use INSERT SQL statement
and it will work muck faster.
Another question is why are you trying to use COM-based ADO with C#. If you
move to C#, then use ADO.NET managed class. Otherwise you might face some
limitations with using ADO through COM Interop
Hard to say why you get this error. It depends what is your actual code. As
I understand this is not a full code.
-- Val Mazur Microsoft MVP "Microsoft" <graham@integra.uk.net> wrote in message news:OCYWVNgWEHA.3984@TK2MSFTNGP09.phx.gbl... > Hi, i hope someone can help. The following code works in VB: > Dim sql As String > Dim oconn As New ADODB.Connection > Dim ors As New ADODB.Recordset > oconn.ConnectionString = "...." > oconn.Open > sql = "SELECT * FROM Table" > ors.CursorLocation = adUseClient > ors.LockType = adLockBatchOptimistic > ors.Open sql, oconn > ors.AddNew > ors(1) = ... > oRS(2) = ... > ors.UpdateBatch > Dim newid As Integer > newid = ors(0) > > When I do exactly the same in c# the UpdateBatch fails, saying that it > would > create a duplicate key. Any ideas? > Regds > Graham > >
- Next message: Val Mazur: "Re: VBscript Error 800a01a8 on Connection.Close"
- Previous message: Douglas Laudenschlager [MS]: "Re: VC++ connect string for Excel 2002?"
- In reply to: Microsoft: "Insert to Access DB with Autonumber field"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|