By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,415 Members | 1,568 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,415 IT Pros & Developers. It's quick & easy.

Parameter query problem

P: 3
Hello
Anybody knows how parameter can be passed in correctly:
There are 2 table, "sp" is one of the table that will be used depending on a session. I need to pass a dropdownlist value into the query like:

table123.ID = ddlItem.SelectedValue;
GetLists(table123);

Expand|Select|Wrap|Line Numbers
  1. public DataSet GetLists(table123 pref)
  2. {
  3. new SqlCommand("select b.ID2 from " + sp + " a, tb2 b where a.ID=b.ID and d.ID=@id", cn);
  4.  
  5. cm.Connection = cn;
  6.  
  7. cm.Parameters.Add(p1);
  8.  
  9. cm.Parameters[@id].Value = pref;
  10.  
  11. ds = new DataSet();
  12.  
  13. da = new SqlDataAdapter(cm);
  14.  
  15. da.Fill(ds, "GetLists"); 
  16.  
  17. return ds;
  18.  
  19. }
  20.  
Jun 29 '09 #1
Share this Question
Share on Google+
1 Reply


OuTCasT
100+
P: 374
Dim ex as string
ex = ddlItem.SelectedValue

then pass ex to the query string.
Jun 30 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.