my table:
id address tag
1 test class1
2 test1 class2
3 test3 class3
In UI i am displaying all tag names as checkboxes.
When user selects one or more tag names then need to get required address values. how to get?
if user selects class1,class2 in UI then need to get test,test1 as result.
Please tell me how to write query in sqlserver 2008 for that.
EDIT CODE :
taglist = "class1,class2";
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
SqlCommand cmd = new SqlCommand("usp_GetTags", con);
cmd.Parameters.Add("@Tags", SqlDbType.VarChar).Value = taglist;
con.Open();
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
while passing the parameters as above not getting any results.if i pass single taglist=class1 getting results.but taglist=”class1,class2″ not getting any resuls.please tell me how to pass multiple parameters from UI.
You can write the query in sql server by using the
INkeyword.EDIT:
Add the parameters with values to the stored procedure like this. The below code is written in C#.net
EDIT 2:
Its very simple to put in a single string all the values, accordingly your query also suits that. Write the query in your stored procedure like
and in your coding part write like follow
EDIT 3:
Finally i found the solution for your problem. Write your stored procedure as below
and also send the parameters SingleParameter as below