我在表单上有一个文本框和一个按钮。使用Vb.net中的IN子句将某些内容保存到使用SQL的数据库中
我希望运行一个查询(在Vb.Net中),它将产生一个IN值的查询。
下面是我的代码示例
myConnection = New SqlConnection("Data Source=sqldb\;Initial Catalog=Rec;Integrated Security=True")
myConnection.Open()
myCommand = New SqlCommand("UPDATE dbo.Recordings SET Status = 0 where RecID in ('" & txtRecID.Text & "') ", myConnection)
ra = myCommand.ExecuteNonQuery()
myConnection.Close()
MsgBox("Done!", _
MsgBoxStyle.Information, "Done")
当我进入它的工作原理单个值,但是当我输入值之间用逗号它抛出一个错误:
"Conversion failed when converting the varchar value '1234,4567' to data type int."
可能有人请帮助我解决这个问题还是有其他方法?
非常感谢
改为尝试'MsgBox(myCommand.CommandText)'。你会看到它。 – GSerg 2010-09-30 10:31:30