c# - ODBC must declare the scalar variable -
consider code below:
string connectionstring = "dsn=mysql;uid=sa;database=userdb;"; string qrystr = "insert info(code) values(@code);"; odbcconnection con = new odbcconnection(connectionstring); odbccommand cmd = new odbccommand(qrystr,con ); cmd.parameters.add("@code", system.data.odbc.odbctype.int).value = "999"; cmd.connection.open(); odbcdatareader odbcdtr = cmd.executereader();//exception "must declare scalar variable @code" con.close; this code raising exception "must declare scalar vairable @code". i'll grateful if can point out mistake in code above.
i've found solution given in this link.
the odbc interface not recognise use of @named variables, ? taken position. can use ?param1, ?param 2 readability, position used.
Comments
Post a Comment