0

Does SqlDataAdapter Requires open connection To Execute Sql Command ?

see below :

protected void Page_Load(object sender, EventArgs e)
    {
        string strconn = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
        SqlConnection con = new SqlConnection(strconn);            
        SqlCommand cmd = new SqlCommand("Select * from EmpDetails", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);           
        DataSet ds = new DataSet();           
        da.Fill(ds);           
        GV_Data.DataSource = ds;
        GV_Data.DataBind();
    }    

anyone have a clue about this ?

1
  • Did you note anything gone strange? Commented Nov 7, 2017 at 11:47

1 Answer 1

1

No. A DataAdapter will open a closed connection automatically, before it fills a dataset/table. It will also return the connection to the state it was before the fill operation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.