Connecting Tech Pros Worldwide Forums | Help | Site Map

Parameter query problem

Newbie
 
Join Date: Jun 2009
Posts: 3
#1: Jun 29 '09
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.  
OuTCasT's Avatar
Needs Regular Fix
 
Join Date: Jan 2008
Location: South Africa
Posts: 354
#2: Jun 30 '09

re: Parameter query problem


Dim ex as string
ex = ddlItem.SelectedValue

then pass ex to the query string.
Reply