更新时间:2022-03-19 23:26:20
根据MSDN.
http://msdn.microsoft.com/en -us/library/system.data.odbc.odbccommand.parameters.aspx
According to MSDN.
http://msdn.microsoft.com/en-us/library/system.data.odbc.odbccommand.parameters.aspx
当CommandType设置为Text时,用于ODBC的.NET Framework数据提供程序不支持将命名参数传递给SQL语句或OdbcCommand调用的存储过程.在这两种情况下,均使用问号(?)占位符.
When CommandType is set to Text, the .NET Framework Data Provider for ODBC does not support passing named parameters to an SQL statement or to a stored procedure called by an OdbcCommand. In either of these cases, use the question mark (?) placeholder.
所以您的查询应该是:
string sql = "insert into klant (firstname) values (?)"
string sql = "insert into klant (firstname) values (?)"
如果您有多个参数,则会按照添加它们的顺序进行设置.
If you have multiple parameters, they are set in the order you add them.
此外,我认为这行
string firstname = txtfirstname.ToString();
应阅读
string firstname = txtfirstname.Text();
但这不是引起您直接问题的原因.
But that is not what is causing your immediate problem.