Friday, November 29, 2013

Error Fill: SelectCommand.Connection property has not been intialized in asp.net

Leave a Comment
The above mentioned error whose screenshot is given below in asp.net is caused when trying to run fill() function of DataAdapter.


How to Solve Error  Fill: SelectCommand.Connection property has not been intialized in asp.net

To solve this error pass the connection object to dataadapter.
Syntax would be:
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
con.Open();
DataSet ds = new DataSet();
SqlDataAdapter adp = new SqlDataAdapter("select * from tblname", con);

adp.Fill(ds);

0 comments:

Post a Comment