Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View runtime updatecommand parameters?

Status
Not open for further replies.

SJG0526

Programmer
Jul 5, 2002
108
0
0
US
I have the following code:

Code:
            sSql = "UPDATE tblShippers SET ShipperKey = ?, " & _
                                        "Description = ?, " & _
                                        "MaxWeight = ?, " & _
                                        "TStamp = '" & Now() & "' " & _
                                        " WHERE ShipperUID = ?"
            da.UpdateCommand = New OleDbCommand(sSql, Conn)
            da.UpdateCommand.Parameters.Add("@ShipperKey", OleDbType.Char, 10, "ShipperKey")
            da.UpdateCommand.Parameters.Add("@Description", OleDbType.Char, 100, "Description")
            da.UpdateCommand.Parameters.Add("@MaxWeight", OleDbType.Double, "MaxWeight")
            da.UpdateCommand.Parameters.Add("@oldShipperUID", OleDbType.Integer, "ShipperUID").SourceVersion = DataRowVersion.Original

When I run the ds.Update command, I'm not getting an error but its not updating the record. I'd like to see what values are being used for the parameters when its bombing out. Any way to do this?
 
Your SQL is not referencing the parameters:

sSql = "UPDATE tblShippers SET ShipperKey = [red]@ShipperKey[/red], " & _
"Description = [red]@Description[/red], " & _
"MaxWeight = [red]@MaxWeight[/red], " & _
"TStamp = '" & Now() & "' " & _
" WHERE ShipperUID = [red]@oldShipperUID[/red]"

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
The help says to use ? for the parameters in the sql statement when it goes against an odbc data source - in this case Access.
 
Well, from your code it seems that you are not using ODBC, but are using OleDb:

da.UpdateCommand = New [red]OleDb[/red]Command(sSql, Conn)

Besides, how would the command object know which parameter to put with which question mark?

Which help entry is giving you this advice?

I suspect it is a misprint, or the author intended to go back and replace the question marks with the parameters and never did so.

Try using the parameter names, it should work.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Sorry! I meant oledb.
Here's the link in the VS2005 help:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/WD_ADONET/html/f21e6aba-b76d-46ad-a83e-2ad8e0af1e12.htm

In any event, I just want to see if there is a way to trace what happens during an update command against an Access database. I know in SQL Server I can use the tracing and view what parameters are being used but not sure how to do this with Access data.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top