C# and MS Access parameter passing
-
hello every body, I usually work with sql server so if anybody may help with MS Access I'd be thankful. here 's my C# potion of code: string selectId = "select categoryId from Category where categoryName = @catName"; myCommand = new OdbcCommand(selectId,myConn); myCommand.Parameters.Add("@catName",categoryName.ToString()); myCommand.prepare(); myReader = myCommand.ExecuteReader(); at this level an exeption is thrown at the level of the odbc driver it says not enough parameters or something. 1 parameter missing. In my string i'm having only one parameter and it's @catName. in the definition of the Add()function it says that the second parameter is the value of the named parameter. The function that contains this code receives the value of categoryName however it's not set! can anybody help pls
-
hello every body, I usually work with sql server so if anybody may help with MS Access I'd be thankful. here 's my C# potion of code: string selectId = "select categoryId from Category where categoryName = @catName"; myCommand = new OdbcCommand(selectId,myConn); myCommand.Parameters.Add("@catName",categoryName.ToString()); myCommand.prepare(); myReader = myCommand.ExecuteReader(); at this level an exeption is thrown at the level of the odbc driver it says not enough parameters or something. 1 parameter missing. In my string i'm having only one parameter and it's @catName. in the definition of the Add()function it says that the second parameter is the value of the named parameter. The function that contains this code receives the value of categoryName however it's not set! can anybody help pls
Should be this...?
myCommand.Parameters.Add("catName",categoryName.ToString());