Fill DataSet In Asp.net C#
Introduction :
Calling the method :
Method to bind dataset :
Introduction :
In this article i will show how to fill dataset from database sql server using c# language .For this i have created common methodh in which you have just pass the query and it automatically return the filled dataset .GetDataSet function contains the easy code to fill the dataset .
Calling the method :
DataSet Ds = GetDataSet("Select * from Tablename");
Method to bind dataset :
private DataSet GetDataSet(string Query) { DataSet Ds = new DataSet(); try { string strCon =""; // set connetion string here .. SqlConnection Con = new SqlConnection(strCon); SqlDataAdapter Da = new SqlDataAdapter(Query, Con); Da.Fill(Ds); } catch (Exception) { } return Ds; }