Hi
This is a strange one.
I am updating an Access table from a DataTable and the same record is inserted multiple times when using a stored procedure but works OK if I build the update query in a string.
I am performing the update like this:-
I have the following stored procedure:-
Now if the DataTable has four new rows, each with a different nameserverID then the first nameserverID is added four times. However, if I change it over to:-
And put the exact same SQL query in the sSQL string it works great and the four different records are inserted.
Anyone have any ideas on this. Is there a known issue when updating a table in Access from a DataTable using Stored Procedures. I have searched but cannot find anything.
Thanks for looking
This is a strange one.
I am updating an Access table from a DataTable and the same record is inserted multiple times when using a stored procedure but works OK if I build the update query in a string.
I am performing the update like this:-
Code:
daDataAdapter.InsertCommand = New OleDb.OleDbCommand("QRY_INSERT_LK_Domains_NameServers", cnSQL)
daDataAdapter.InsertCommand.CommandType = CommandType.StoredProcedure
daDataAdapter.InsertCommand.Transaction = txSQL
WorkParam = New OleDbParameter
WorkParam = daDataAdapter.InsertCommand.Parameters.Add("@iDomainID", OleDbType.Integer)
WorkParam.Value = iDomainID
WorkParam = New OleDbParameter
WorkParam = daDataAdapter.InsertCommand.Parameters.Add("@iNameServerID", OleDbType.Integer)
WorkParam.SourceColumn = "FK_NameServers_ID"
WorkParam.SourceVersion = DataRowVersion.Current
daDataAdapter.Update(dsDomain, "NameServers")
I have the following stored procedure:-
Code:
INSERT INTO LK_Domains_NameServers ( FK_Domains_ID, FK_NameServers_ID )
VALUES ([@iDomainID], [@iNameServerID]);
Now if the DataTable has four new rows, each with a different nameserverID then the first nameserverID is added four times. However, if I change it over to:-
Code:
daDataAdapter.InsertCommand = New OleDb.OleDbCommand(sSQL, cnSQL)
daDataAdapter.InsertCommand.CommandType = CommandType.Text
daDataAdapter.InsertCommand.Transaction = txSQL
And put the exact same SQL query in the sSQL string it works great and the four different records are inserted.
Anyone have any ideas on this. Is there a known issue when updating a table in Access from a DataTable using Stored Procedures. I have searched but cannot find anything.
Thanks for looking