Re: How to do a simple update command with ado.net?



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.
>


.



Relevant Pages

  • Re: insert Q
    ... many sql statements on the page). ... When you use a connection's Execute method, a Command object is ... Always use an explicit recordset object: ...
    (microsoft.public.inetserver.asp.db)
  • Re: COBOL stored procedure for DB2
    ... Regarding how you precompile the app, you must specify target mfcob to db2 prep, rather than target ibmcob. ... Have you also confirmed that, prior to executing the CALL statement, the host variables specified within the client app have the appropriate values? ... MODIFIES SQL DATA ... confirm the cob command used for creating the SP module. ...
    (comp.lang.cobol)
  • Re: Running a program from a SQL job
    ... This will allow you to go to a SQL prompt:- ... >> Use XP_CMDSHELL to fire a OS command from command prompt. ... I've made a bat file that contains the string to run to ... When I set the SQL job to execute the same ...
    (microsoft.public.sqlserver.server)
  • Re: insert Q
    ... >> conn.execute SQL ... When you use a connection's Execute method, a Command object is ... Always use an explicit recordset object: ...
    (microsoft.public.inetserver.asp.db)
  • Re: MultiThreading against a Procedure
    ... Then someone needs to tell the Sql Profiler team that the application does ... I DID run profiler against the process to see what was happening. ... You should not have to rebuild or dispose of the Command objects between ... I can't change the procedure to just execute from '1/1/2001' to ...
    (microsoft.public.dotnet.framework.adonet)