|
Generic ASP.NET Database Functions
This is for a straight select that i need to fill a dataset
Here is what I use to fill a datatable
NOTICE: this is returning a DataTable, as that is what I need 99% of of the
time, not a DataSet.
public DataTable GetDataTable(string SQL,string ConnectString)
{
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter(SQL,ConnectString);
adapter.Fill(ds,"DataTable");
return ds.Tables["DataTable"];
}
Here is what i use for Inserts and Updates
public bool Execute(string SQL, string ConnectString)
{
SqlConnection conn = new SqlConnection(ConnectString);
SqlCommand cmd = new SqlCommand(SQL,conn);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
}
|
|