Re: How to do a simple update command with ado.net?
- From: "Earl" <brikshoe@xxxxxxxxxxxxxxxxx>
- Date: Mon, 1 Aug 2005 20:11:23 -0500
I believe your SQL is incorrect. Note the single parens differences. Set a
breakpoint past your SQL line and then pass your cursor over the top to
check the string syntax. But as Bill says, command objects make it much
easier to find these sorts of issues.
sSQL = "UPDATE NoteTable SET AcctID = "'" & Account.sAcctID & "'"
sSQL = sSQL & " WHERE AcctNo = " & "'" & Account.sAccountNo & "'"
"Sean" <nbSean@xxxxxxxxx> wrote in message
news:1122915481.926277.60930@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>I am trying to execute a simple SQL Update command on an Access
> database. I have an OleDBConnection (gDatabaseConn) that has
> successfully been executing select commands, but I cannot get an update
> command to work. Here is the code in question:
>
> Dim cmdUpdate As New OleDb.OleDbCommand("", gDatabaseConn)
>
> sSQL = "UPDATE NoteTable SET AcctID = '" & Account.sAcctID
> sSQL = sSQL & "' WHERE AcctNo = '" & Account.sAccountNo & "'"
>
> cmdUpdate.CommandText = sSQL
> cmdUpdate.ExecuteNonQuery()
>
> The call to ExecuteNonQuery throws an exception with the message "No
> value given for one or more required parameters". Both of the
> variables used in the string have values. Is ADO.NET capable of
> running a simple SQL command like this, or do I need to investigate
> OleDBParameter objects? This way would be preferrable, since I am not
> using DataTables or DataRows.
>
.
- References:
- Prev by Date: Re: sqltransaction and updates to multiple databases
- Next by Date: Re: Check to ensure server and db available
- Previous by thread: Re: How to do a simple update command with ado.net?
- Next by thread: Re: How to do a simple update command with ado.net?
- Index(es):
Relevant Pages
|