command对象形式如下:
where a in (?)
现在想传送如下的值 'a1','b1','c1'
请问有什么办法传送吗?
如果这样设置 parameter(a).value= " a "这个查询 有结果
parameter(a).value= " a,b,c " 这个查询就没有结果了,加引号 也不行
...全文
15911打赏收藏
如何向command对象的一个参数传多个值(如何使用IN条件查询)
command对象形式如下: where a in (?) 现在想传送如下的值 'a1','b1','c1' 请问有什么办法传送吗? 如果这样设置 parameter(a).value= " a "这个查询 有结果 parameter(a).value= " a,b,c " 这个查询就没有结果了,加引号 也不行
Dim Cnn As New SqlClient.SqlConnection(MdlCommon.CnnString)
Dim Cmd As New SqlClient.SqlCommand()
Cmd.CommandType = CommandType.StoredProcedure
Cmd.Connection = Cnn
Try
Cnn.Open()
Cmd.Parameters.Add("@ColorNo", TxtColorNo.Text.Trim)
Cmd.Parameters.Add("@ColorName", TxtColor.Text.Trim)
Cmd.Parameters.Add("@ColorRemark", TxtRemark.Text.Trim)
Cmd.Parameters.Add("@ColorUserID", MdlCommon.UserID)
If New_Record = True Then
Cmd.CommandText = "InsertIntoColor"
Else
Cmd.Parameters.Add("@dbColorNo", dbColorNo)
Cmd.CommandText = "UpdateColor"
End If
Cmd.ExecuteNonQuery()