469,643 Members | 2,061 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

ODBC Parameter Error

I am getting an error: ERROR [07002] [Microsoft][ODBC Microsoft Access
Driver] Too few parameters. Expected 1 with the following code:

public static string GetTitle(int CatID)
{
OdbcConnection conn = new
OdbcConnection(ConfigurationSettings.AppSettings["ConnString"]);
OdbcCommand command = new OdbcCommand("SELECT Category FROM Categories
WHERE CategoryID = @CID", conn);
conn.Open();
command.Parameters.Add(new OdbcParameter("@CID", OdbcType.Int));
command.Parameters["@CID"].Value = CatID;
OdbcDataReader reader =
command.ExecuteReader(CommandBehavior.CloseConnect ion);
reader.Read();
string s = Convert.ToString(reader["Category"]);
conn.Close();
return s;
}

I have to use a DSN and the ODBC Connection. Is it a problem with my
parameter?

Thanks,
Marty


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
0 1042

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by GitarJake | last post: by
5 posts views Thread by Todd Huish | last post: by
reply views Thread by Marco Martin | last post: by
3 posts views Thread by juststarter | last post: by
1 post views Thread by chloe.crowder | last post: by
4 posts views Thread by Szymon Dembek | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.