我在表單上有一個文本框和一個按鈕。使用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