forum

Home / DeveloperSection / Forums / The SelectCommand property has not been initialized before calling “Fill

The SelectCommand property has not been initialized before calling “Fill

Anonymous User288019-Jun-2013
Hi Developers,

The SelectCommand property has not been initialized before calling “Fill

My line of code as following

SqlConnection cn = new SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\MANTHAN\Documents\Visual Studio 2010\WebSites\sample\App_Data\Database.mdf;Integrated Security=True;User Instance=True");
    SqlCommand cmd = new SqlCommand("SELECT * FROM stu1", cn);
    SqlDataAdapter adp = new SqlDataAdapter(cmd);

    DataSet ds = new DataSet();

    adp.Fill(ds);

    GridView1.DataSource = ds.Tables[0];

Updated on 19-Jun-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By