我从那里将数据导入数据库的csv。

myCommand.Parameters.Add("@cn", SqlDbType.Text);
myCommand.Parameters["@cn"].Value = comp.Rows[i][1].ToString();


如果comp.Rows[i][1]的值为X'496e626randomcharacters',则会收到此错误:The floating point value '496e626' is out of the range of computer representation (8 bytes). Incorrect syntax near '496e626'.

应该将其作为字符串/文本来处理,所以我不理解浮点错误。
怎么了

最佳答案

使用

 SqlDbType.VarChar


而不是

 SqlDbType.Text



  SqlDbType.Text:字符串。非Unicode数据的可变长度流
  的最大长度为2 31 -1(或2,147,483,647)个字符。


Ref

关于c# - 参数化的sql查询问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21113761/

10-09 18:26