Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i m getting error in this line

SqlDataAdapter fgrid = new SqlDataAdapter("Select Date,Item_Code,Quantity,ID From Finished_Goods_Stock Where Date = @f_date,Item_Code = @f_code", connection_v);


for SqlCommand variables are declared like this
fgrid.Parameters.Addwithvalue("@f_date",@f_date);

so wht to do for dataadapter?
Posted

Use Parameters according to MSDN MSDN[^]

But it's wrong: there is no SqlDataAdapter.Parameters. Use this:
using (SqlConnection connection_v = new SqlConnection(strCon))
    {
    SqlDataAdapter fgrid = new SqlDataAdapter("Select Date,Item_Code,Quantity,ID From Finished_Goods_Stock Where Date = @f_date,Item_Code = @f_code", connection_v);
    fgrid.SelectCommand.Parameters.AddWithValue("@f_date", DateTime.Now);
    ...
    }
 
Share this answer
 
Comments
Sweety Khan 20-Jun-11 3:35am    
thanx its done :)
See this [^] - this explains how to use parameters with Data Adapters quite accurately.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900