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

Go to topic 5063

Return to index page 749
Return to index page 748
Return to index page 747
Return to index page 746
Return to index page 745
Return to index page 744
Return to index page 743
Return to index page 742
Return to index page 741
Return to index page 740