Gamecode
asked on
ExecuteNonQuery error Missing Parameters
Can somebody tell me why this code is not working? when I get to the line with the ExecuteNonQuery I get an error called "one or more parameters missing".
I use a similar code for both inserting and deleting data and those are working fine.
The code is writen in Microsoft Visual c# express and I am using a access database.
I use a similar code for both inserting and deleting data and those are working fine.
The code is writen in Microsoft Visual c# express and I am using a access database.
string SQLUpdateString = "UPDATE tblKunde SET firmaNavn=" + firmanavn + " WHERE IdKunde=" + idkunde + "";
OleDbCommand SQLCommand = new OleDbCommand(SQLUpdateString, f1.database);
try
{
int response = SQLCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanx that did the trick, I just don't understand why this problem occurs only when updating the database and not when I insert or delete, but thanx for the quick respons :)
ASKER
Okay I get it, it's because the update statement needs aprostofs, so I need to trick the c# code a little thanx again.
Sorry, the new update string is here:
string SQLUpdateString = String.Format("UPDATE tblKunde SET firmaNavn='{0}' WHERE IdKunde='{1}'", firmanavn, idkunde);
string SQLUpdateString = String.Format("UPDATE tblKunde SET firmaNavn='{0}' WHERE IdKunde='{1}'", firmanavn, idkunde);
See http://www.w3schools.com/SQl/sql_update.asp