Hi
I want to run an Updatequery against my Access DB, but it writes the false
Value into the Table.
Code:
string oleConnectionSt ring = "Provider=..... ...";
string update = "UPDATE Formate SET Entry = @name WHERE ID = 1";
OleDbConnection oleConnection = new OleDbConnection (oleConnectionS tring);
OleDbCommand oleCommand = new OleDbCommand(up date,oleConnect ion);
oleCommand.Para meters.Add("@an yValueName",999 );
oleCommand.Para meters.Add("@na me","Test Entry");
try
{
oleConnection.O pen();
oleCommand.Exec uteNonQuery();
}
catch(Exception ex)
{
throw new Exception(ex.Me ssage);
}
finally
{
if(oleConnectio n.State == ConnectionState .Open)
oleConnection.C lose();
}
ExecuteNonQuery writes 999 in the Field Entry instead of TestEntry.
WHY???
I've tried different things, and the result was that the only way to get the
correct result, when I pass the values in the Parameters Collection in the
same order as the Values in the SqlQuery.
Example:
UPDATE tablename SET value1 = @value1, value2=@value2 WHERE blablabla
..Parameters.Ad d("@value1",123 45);
..Parameters.Ad d("@value2","An y Text");
Has anybody an idea??
thx
I want to run an Updatequery against my Access DB, but it writes the false
Value into the Table.
Code:
string oleConnectionSt ring = "Provider=..... ...";
string update = "UPDATE Formate SET Entry = @name WHERE ID = 1";
OleDbConnection oleConnection = new OleDbConnection (oleConnectionS tring);
OleDbCommand oleCommand = new OleDbCommand(up date,oleConnect ion);
oleCommand.Para meters.Add("@an yValueName",999 );
oleCommand.Para meters.Add("@na me","Test Entry");
try
{
oleConnection.O pen();
oleCommand.Exec uteNonQuery();
}
catch(Exception ex)
{
throw new Exception(ex.Me ssage);
}
finally
{
if(oleConnectio n.State == ConnectionState .Open)
oleConnection.C lose();
}
ExecuteNonQuery writes 999 in the Field Entry instead of TestEntry.
WHY???
I've tried different things, and the result was that the only way to get the
correct result, when I pass the values in the Parameters Collection in the
same order as the Values in the SqlQuery.
Example:
UPDATE tablename SET value1 = @value1, value2=@value2 WHERE blablabla
..Parameters.Ad d("@value1",123 45);
..Parameters.Ad d("@value2","An y Text");
Has anybody an idea??
thx