: Not totally sure I get what you are describing.... But if you have a field set as an Primary Key in your DB and it is a 'Identity' or 'AutoIncrementing' field, you do not put that field in the 'INSERT' statement the DB will do that itself.... likewise it should be excluded for any 'UPDATE' statements. Are you creating these SQL statements yourself, or is there an object doing that work? I don't work much with the UI objects that do create the statements, but I would imagine there either an option to exclude 'identity' fields, or you could manually edit the statement it created to remvoe them before running it.
:
: Second, if necessary you can tell SQL Server, if that is what you are using, to turn the constraint for Identity fields off if you are importing data into it in a block... ALthough, obviously you would have to verify the values are not duplicated yourself.
:
: ~rlc
:
:
Hi,
I use the Microsoft.Jet.OLEDB.4.0 dataprovider.
An example to give you an idea:
Private oConnection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & apppath & "db1.mdb;" & "Jet OLEDB:Database Password=db1")
Private oDataSet As New DataSet()
Private oDataAdapter As New OleDb.OleDbDataAdapter()
Private oSelectCommand As New OleDb.OleDbCommand("Select Name, Adres, ID From CustomerTable", oConnection)
Private oInsertCommand As New OleDb.OleDbCommand("Insert into CustomerTable(Name, Adres, ID) Values (@Name, @Adres, @ID)", oConnection)
Private oUpdateCommand As New OleDb.OleDbCommand("Update CustomerTable Set Name = @Name, Adres = @Adres, Where ID = @ID", oConnection)
Private oDeleteCommand As New OleDb.OleDbCommand("Delete From CustomerTable Where ID = @ID", oConnection)
'Create Update statement
oUpdateCommand.Parameters.Add(New OleDb.OleDbParameter("@Name", System.Data.SqlDbType.NVarChar, 20, System.Data.ParameterDirection.Input, True, CType(0, Byte), CType(0, Byte), "Naam", System.Data.DataRowVersion.Current, Nothing))
oUpdateCommand.Parameters.Add(New OleDb.OleDbParameter("@Adres", System.Data.SqlDbType.NVarChar, 20, System.Data.ParameterDirection.Input, True, CType(0, Byte), CType(0, Byte), "Adres", System.Data.DataRowVersion.Current, Nothing))
oUpdateCommand.Parameters.Add(New OleDb.OleDbParameter("@ID", System.Data.SqlDbType.Int, 5, System.Data.ParameterDirection.Input, True, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Current, Nothing))
VBnewbie