How to use OdbcParameter for MySQL?

后端 未结 1 845
忘掉有多难
忘掉有多难 2021-01-25 06:14

How to use OdbcParameter for MySQL?

This is my current attempt:

command.Parameters.Add(new OdbcParameter(\"@username\",         


        
1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-25 06:31

    Change your CommandText to be a valid one for OdbcCommand:

    command.CommandText = "INSERT INTO test.test (`user`,`password`) VALUES (? , ?);";
    

    Instead of the parameter name as @paramname, it takes a ? in the CommandText - leave the name in the actual parameters.

    See this blog post for an example.

    0 讨论(0)
提交回复
热议问题