Tuesday, January 26, 2010

Use Of Data table and Dataset

SqlCommand mySqlSelect = new SqlCommand(“select * from tbl_test where nid=’” + Session["nid"].ToString() + “‘ and sessionid=’” + Session["sid"].ToString() + “‘”, conn);
mySqlSelect.CommandType = CommandType.Text;
SqlDataAdapter mySqlAdapter = new SqlDataAdapter(mySqlSelect);
DataSet myDataSet = new DataSet();
mySqlAdapter.Fill(myDataSet);
// Convert DataSet to DataTable by getting DataTable at first zero-based index of DataTableCollection
DataTable dtr1 = myDataSet.Tables[0];