[英](?,?…?) or (@field1,@field2…@fieldn) in parmeterized queries?
Is this bad coding? 这是不好的编码?
I have a query 我有一个问题
INSERT INTO sometable (field1,field2...fieldn) VALUES (?,?,.....?)
Then 然后
cmd.Parameters.Add("TOFnr", OdbcType.Int, 10).Value = orderId;
cmd.Parameters.Add("LineNr", OdbcType.Int, 10).Value = maxLineNr;
cmd.Parameters.Add("Date", OdbcType.VarChar, 8).Value = rowHeader["Date"];
The code works, except there was an if-conditional around an Add, causing the data after that line to get into the wrong variable. 该代码有效,除了在Add周围有一个if条件,导致该行之后的数据进入错误的变量。
The placeholders ("TOFnr" etc.) is only used for the programmers reference, not used by the sql or c# itself, right? 占位符(“TOFnr”等)仅用于程序员引用,不是由sql或c#本身使用,对吗?
Isn't it less error-prone to used named parameters in the query? 在查询中使用命名参数不是很容易出错吗?
INSERT INTO sometable (field1,field2...fieldn) VALUES (@TOFnr,@LineNr,.....@fieldn)
It is c# connecting to borland paradox over odbc. 这是c#连接到odbc的borland悖论。
Isn't it less error-prone to used named parameters in the query?
在查询中使用命名参数不是很容易出错吗?
Yes, it is. 是的。 Unfortunately the ADO.NET ODBC driver doesn't allow named SQL parameters to be passed along in the SQL statement, so unfortunately for you, it is not possible using the ODBC driver.
遗憾的是,ADO.NET ODBC驱动程序不允许在SQL语句中传递命名的SQL参数,因此不幸的是,使用ODBC驱动程序是不可能的。
I am not an expert on Paradox, but there might be a driver specifically for Paradox which does allow named parameters. 我不是Paradox的专家,但可能有专门针对Paradox的驱动程序,它允许命名参数。 You might have more luck there.
你可能会有更多的运气。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.