K
Kay
Hello,
I am having a problem with passing a comma delimited string as a parameter
to be used in the IN() clause for a record selection. What I want to do is
select all customer who have a surname that matches one in a specified list,
which I pass in as a parameter to the query. I am working in VS.Net and
through the designer set up a Sql Command object, the following is generated
'SqlCommand1
Me.SqlCommand1.CommandText = "SELECT * FROM Customer WHERE (SurName IN
(@SurNameList))"
Me.SqlCommand1.Connection = Me.SqlConnection1
Me.SqlCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@SurNameList",
System.Data.SqlDbType.VarChar)).
In my code I set SqlCommand1.Parameters("@SurNameList").Value =
"Murphy,Sullivan,Lyons"
I know there are customers with these surnames in the DB but my datareader
is empty. I also have tried "'Murphy','Sullivan','Lyons'" but no good.
Any suggestions very much appreciated,
Thanks,
Kay.
I am having a problem with passing a comma delimited string as a parameter
to be used in the IN() clause for a record selection. What I want to do is
select all customer who have a surname that matches one in a specified list,
which I pass in as a parameter to the query. I am working in VS.Net and
through the designer set up a Sql Command object, the following is generated
'SqlCommand1
Me.SqlCommand1.CommandText = "SELECT * FROM Customer WHERE (SurName IN
(@SurNameList))"
Me.SqlCommand1.Connection = Me.SqlConnection1
Me.SqlCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@SurNameList",
System.Data.SqlDbType.VarChar)).
In my code I set SqlCommand1.Parameters("@SurNameList").Value =
"Murphy,Sullivan,Lyons"
I know there are customers with these surnames in the DB but my datareader
is empty. I also have tried "'Murphy','Sullivan','Lyons'" but no good.
Any suggestions very much appreciated,
Thanks,
Kay.