Problems doing an SQL insert statement on datetimestamp

I get the following error message when trying to run the code posted below...

"Prepared statement '(@datestamp datetime,@PrevValue real,@NewValue real,@IPaddress r' expects parameter @datestamp, which was not supplied."

I have tried the following code with the quotes, without quotes and every other way it seems like. Without the quotes, the statement doesn't like the spaces in the timestamp. What should/could I do to fix this?

My code:

PrivateSub UpdateRefresh()

UpdateConnection.Open()

UpdateDataAdapter.InsertCommand.CommandText = "INSERT INTO dbo.tbDeploy(datestamp," & _

"PrevValue, NewValue, IPaddress, HighCapability, LowCapability, Share) VALUES" & _

"('" & DateTime.Now & "', '" & lblCurrent.Text & "', '" & lblCurrent.Text & _

"', '" & lblIP.Text & "', '" & lblHigh.Text & "', '" & lblLow.Text & "', '" & lblShare.Text & "')"

UpdateDataAdapter.InsertCommand.ExecuteNonQuery()

UpdateConnection.Close()

EndSub

[1425 byte] By [HMote] at [2007-12-24]
# 1

Hi HMote,

First thing I see is that there should be a space between VALUES and the trailing quote....like this...

VALUES "

The other things that come to mind is that is it possible the UpdateDataAdapter hasn't been updated? If you have added the datestamp field, or made any type of change to the field, after you already created the UpdateDataAdapter then you must manually update the UpdateDataAdapter. I would also recommending testing the command in the SQL environment by using the Query Builder or something of similar idea. This will tell you before hand if you are using a good query or not.

I hope the above helps.

Thank you,

James

ReaSoftwareEngineering at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
"Prepared statement", that doesn't sound like a Microsoft database engine term. Are you using MySQL perhaps? Access needs pounds ("#") around a date, SQL server uses single quotes. Check the docs of your database engine to see what it needs.
nobugz at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
You were correct on the space. I fixed the problem by just doing an SQLCommand instead of using the data adapter. I couldn't get it to update with the data adapter, but I wasn't using the data adapter to pull anything into so I didn't need it anyways. Thanks for the responses!
HMote at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4
It's ASP.NET 1.1 using VB.NET (VS 2003) trying to pull info out of a SQL Server 2005 DB. You were right about the single quotes. Thanks for the response!
HMote at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...