M
MW
Hello,
I have a problem with parameters in OleDbCommand in Access 2000 database.
For example this code works and updates the row:
OleDbCommand comm = new OleDbCommand("UPDATE DataTable SET ContactID =
'Marcin', Test = 'just a test' WHERE RowID = @RowID ;",
this.databaseConnection);
comm.Parameters.Add("@RowID", OleDbType.Integer);
comm.Parameters["@RowID"].Value = 14;
But if I just change immediate substitution from ContactID to a parameter,
nothing works. Does anyone have any idea why it happens this way ?
OleDbCommand comm = new OleDbCommand("UPDATE DataTable SET ContactID =
@ContactID, Test = 'just a test' WHERE RowID = @RowID ;",
this.databaseConnection);
comm.Parameters.Add("@RowID", OleDbType.Integer);
comm.Parameters.Add("@ContactID", OleDbType.VarWChar, 50);
comm.Parameters["@RowID"].Value = 14;
comm.Parameters["@ContactID"].Value = "Marcin Mastah";
Above code, strangly doesn't work. Any ideas why?
Thanks a lot for all the help
I have a problem with parameters in OleDbCommand in Access 2000 database.
For example this code works and updates the row:
OleDbCommand comm = new OleDbCommand("UPDATE DataTable SET ContactID =
'Marcin', Test = 'just a test' WHERE RowID = @RowID ;",
this.databaseConnection);
comm.Parameters.Add("@RowID", OleDbType.Integer);
comm.Parameters["@RowID"].Value = 14;
But if I just change immediate substitution from ContactID to a parameter,
nothing works. Does anyone have any idea why it happens this way ?
OleDbCommand comm = new OleDbCommand("UPDATE DataTable SET ContactID =
@ContactID, Test = 'just a test' WHERE RowID = @RowID ;",
this.databaseConnection);
comm.Parameters.Add("@RowID", OleDbType.Integer);
comm.Parameters.Add("@ContactID", OleDbType.VarWChar, 50);
comm.Parameters["@RowID"].Value = 14;
comm.Parameters["@ContactID"].Value = "Marcin Mastah";
Above code, strangly doesn't work. Any ideas why?
Thanks a lot for all the help