Insert to Access DB with Autonumber field
From: Microsoft (graham_at_integra.uk.net)
Date: 06/24/04
- Previous message: Jon Blues: "Re: Which is the best provider for SQL Server 2000 and VB6"
- Next in thread: Val Mazur: "Re: Insert to Access DB with Autonumber field"
- Reply: Val Mazur: "Re: Insert to Access DB with Autonumber field"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 24 Jun 2004 16:53:05 +0100
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
- Previous message: Jon Blues: "Re: Which is the best provider for SQL Server 2000 and VB6"
- Next in thread: Val Mazur: "Re: Insert to Access DB with Autonumber field"
- Reply: Val Mazur: "Re: Insert to Access DB with Autonumber field"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|