dtc[0].Rows[0]["admin_first_name"] = "Amadeo";
string updstr = @"UPDATE admins SET admin_first_name=@admin_first_name " +
"WHERE admins.id_admin=@id_admin";
OdbcCommand com = new OdbcCommand(updstr, odbcConn);
com.Parameters.Add("@admin_first_name", OdbcType.NText,50,"admin_first_name");
// i tried by odbcType with : Text,VarChar ,NChar
dbcParameter param= com.Parameters.Add("@id_admin",OdbcType.Int,4,"id_admin");
// and here by odbcType with BigInt, Numeric
param.SourceVersion = DataRowVersion.Original;
odbcDA.UpdateCommand = com;
odbcDA.Update(ds,"admins");
The Error is : Too Few parameters .Expected 2
i think i dont match something at the parameters
The size of the fields must be exactly as long as the one from the Database?
i have put 50 for the Text ( admin_first_name ) in my Database
and long integer for id_admin
Loading
Jan MontanoPosted Feb 1, 2008, 12:45 AM
dtc[0].Rows[0]["admin_first_name"] = "Amadeo";
string updstr = @"UPDATE admins SET admin_first_name=?admin_first_name " +
"WHERE admins.id_admin=?id_admin";
OdbcCommand com = new OdbcCommand(updstr, odbcConn);
com.Parameters.Add("?admin_first_name", OdbcType.NText,50,"admin_first_name");
// i tried by odbcType with : Text,VarChar ,NChar
dbcParameter param= com.Parameters.Add("?id_admin",OdbcType.Int,4,"id_admin");
// and here by odbcType with BigInt, Numeric
param.SourceVersion = DataRowVersion.Original;
odbcDA.UpdateCommand = com;
odbcDA.Update(ds,"admins");
if above does not work try this:
dtc[0].Rows[0]["admin_first_name"] = "Amadeo";
string updstr = @"UPDATE admins SET admin_first_name=? WHERE admins.id_admin=?";
OdbcCommand com = new OdbcCommand(updstr, odbcConn);
com.Parameters.Add().Value = "admin_first_name";
// i tried by odbcType with : Text,VarChar ,NChar
dbcParameter param= com.Parameters.Add().Value = "id_admin";
// and here by odbcType with BigInt, Numeric
param.SourceVersion = DataRowVersion.Original;
odbcDA.UpdateCommand = com;
odbcDA.Update(ds,"admins");
*When CommandType is set to Text, the .NET Framework Data Provider for ODBC does not support passing named parameters to an SQL statement or to a stored procedure called by an OdbcCommand. In either of these cases, use the question mark (?) placeholder.
*OdbcCommand.Parameters Property