problem with odbc

T

TomislaW

This is the code:

OdbcConnection conn = new OdbcConnection(m_ConnectionString);

OdbcDataAdapter adapter = new OdbcDataAdapter();

adapter.SelectCommand = new OdbcCommand("spUser", conn);

OdbcParameter par = new OdbcParameter("@User",OdbcType.VarChar,20);

par.Value=user;

adapter.SelectCommand.Parameters.Add(par);

adapter.Fill(dsUser);



This is the error:

"ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure
'spUser' expects parameter '@User', which was not supplied."



What is wrong here
 
M

Martin Marinov

Try in this way

OdbcConnection conn = new OdbcConnection( m_ConnectionString );
OdbcDataAdapter adapter = new OdbcDataAdapter();
OdbcCommand command = new OdbcCommand();
OdbcParameter par = new OdbcParameter("@User", OdbcType.VarChar, 20 );
par.Value = user;
command.Parameters.Add ( par );
adapter.SelectCommand = command;

adapter.Fill ( dsUser );

Regards
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top