Parameter query problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • naanaa
    New Member
    • Jun 2009
    • 3

    #1

    Parameter query problem

    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.Selecte dValue;
    GetLists(table1 23);

    Code:
    public DataSet GetLists(table123 pref)
    {
    new SqlCommand("select b.ID2 from " + sp + " a, tb2 b where a.ID=b.ID and d.ID=@id", cn);
    
    cm.Connection = cn;
    
    cm.Parameters.Add(p1);
    
    cm.Parameters[@id].Value = pref;
    
    ds = new DataSet();
    
    da = new SqlDataAdapter(cm);
    
    da.Fill(ds, "GetLists"); 
    
    return ds;
    
    }
  • OuTCasT
    Contributor
    • Jan 2008
    • 374

    #2
    Dim ex as string
    ex = ddlItem.Selecte dValue

    then pass ex to the query string.

    Comment

    Working...