C# Prepared Statements - @ sign (at / strudel sign) queries

前端 未结 3 1597
滥情空心
滥情空心 2021-01-11 22:35

I Have a problem with a prepared statement in C#:

OdbcCommand cmd = sql.CreateCommand();
cmd.CommandText = \"SELECT UNIQUE_ID FROM userdetails WHERE USER_ID          


        
3条回答
  •  情话喂你
    2021-01-11 22:57

    Is there a specific reason you're using OdbcCommand rather than using the SqlClient provider?

    With the SqlClient provider, you should be using named parameters as others have suggested.

    But according to MSDN:

    The .NET Framework Data Provider for OLE DB and .NET Framework Data Provider for ODBC do not support named parameters for passing parameters to an SQL statement or a stored procedure. In this case, you must use the question mark (?) placeholder, as in the following example.

    So I'm not sure named parameters will work in this case.

提交回复
热议问题