ODBC Parameter Error

  • Thread starter microsoft.public.dotnet.languages.csharp
  • Start date
M

microsoft.public.dotnet.languages.csharp

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.CloseConnection);
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
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top