Cryptic SQL Error 8178?

G

Guest

Prepared statement '(@KeyNo int, @Key sql_variant) SELECT KeyNo, Key' expects
parameter @KeyNo, which was not supplied.

The following code snippet gives me the above error, what the heck does this
error mean? @KeyNo was supplied, what is it asking for?

SqlCommand mySelectCmd = new SqlCommand();
mySelectCmd.Connection = myConn;
mySelectCmd.Parameters.Add("@KeyNo", SqlDbType.Int, 10, "KeyNo");
mySelectCmd.Parameters.Add("@Key", SqlDbType.Variant, 255, "Key");
mySelectCmd.CommandText = "SELECT KeyNo, Key FROM KeyTable ";
SqlDataAdapter myDA = new SqlDataAdapter();
DataSet myDS = new DataSet();
myDA.SelectCommand = mySelectCmd;
myDA.Fill(myDS,"KeyTable");
 
G

Guest

Nothing cryptic about it. You need to supply a value for the two parameters,
not merely a name. It is easier to see where the error is if you create the
parameters separate from adding them to the select query.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 

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