|
Subject:
|
VB.NET - oledbcommand.parameters BUG
|
|
Posted By:
|
AleBernardi
|
Post Date:
|
4/7/2004 10:31:31 AM
|
Hi! in the book VB.NET of M.Reynolds, R.Blair, J.Crossland, T.Willis there's probably a "bug" about how to set parameters in a OleDbCommand.CommandText property.
vb doesn't care about the parameter name but just about the sequence of the paramenter array. the sample code works fine, but it's a lucky case.
Book's code: --------------------------------------------------------- myCommand.CommandText = "INSERT INTO authors (au_id, au_lname, au_fname, contract) " & _ "VALUES(@au_id,@au_lname,@au_fname,@contract)" myCommand.Parameters.Add("@au_id", txtAuId.Text) myCommand.Parameters.Add("@au_lname", txtLastName.Text) etc... ---------------------------------------------------------
But if you try to exchange parameters, --------------------------------------------------------- myCommand.Parameters.Add("@au_lname", txtLastName.Text) myCommand.Parameters.Add("@au_id", txtAuId.Text) etc... ---------------------------------------------------------
the database field are filled wrong, with the exchanged fields!
I have VS.NET Pro 2003 italian Service Packed and I think that it's a vb bug not reported in the book.
Am I wrong? any suggestion? Thanks you mouch!
(the book is very good I like it much) :)
bye
Alessandro Bernardi BBros snc
|
|
Reply By:
|
Thearon
|
Reply Date:
|
10/9/2004 5:56:27 AM
|
Parameters need to be added to the Parameters collection in the order in which they are defined in either your in-line SQL statements or the stored procedure that you are using.
Thearon
|
|