A
Asif
Hi all,
I am working on a web site using SQL Server 2005 and ASP.NET using
VB.NET.
I am running the following SQL:
Dim oReader As SqlDataReader
Dim IDs As String = "1,2,3"
Dim strSQL As String = "SELECT * FROM Author WHERE ID IN (@IDs)"
' ID field is Primary Key in Author Table
Dim objCmd As New SqlCommand
objCmd.CommandText = strSQL
objCmd.CommandType = CommandType.Text
objCmd.Parameters.Add(New SqlParameter("@TITLE", IDs)
objCmd.Connection = MyConnection
oReader = objCmd.ExecuteReader(CommandBehavior.CloseConnection)
if oReader.HasRows() Then
Do While oReader.Read
MessageBox.Show(oReader.Item(1))
Loop
End If
Above code executes without any error but with no resutls.
Can any one tell me about how to use IN Clause in Parameterized SQL.
Thanks
I am working on a web site using SQL Server 2005 and ASP.NET using
VB.NET.
I am running the following SQL:
Dim oReader As SqlDataReader
Dim IDs As String = "1,2,3"
Dim strSQL As String = "SELECT * FROM Author WHERE ID IN (@IDs)"
' ID field is Primary Key in Author Table
Dim objCmd As New SqlCommand
objCmd.CommandText = strSQL
objCmd.CommandType = CommandType.Text
objCmd.Parameters.Add(New SqlParameter("@TITLE", IDs)
objCmd.Connection = MyConnection
oReader = objCmd.ExecuteReader(CommandBehavior.CloseConnection)
if oReader.HasRows() Then
Do While oReader.Read
MessageBox.Show(oReader.Item(1))
Loop
End If
Above code executes without any error but with no resutls.
Can any one tell me about how to use IN Clause in Parameterized SQL.
Thanks