MS Access and C# Help
-
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
achrafus wrote:
the odbc driver it says not enough parameters or something.
That's a bit vague - What is the EXACT error message? (From other things you've said I think I know what the problem is, but this kind of vague reference to an error message really is not useful and can irritate many people. There are often two similar error messages where the actual root cause is substantially different)
achrafus wrote:
In my string i'm having only one parameter and it's @catName
Access does not use named parameters, use ? (the question-mark) and add the parameters in the order they appear in the query.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog