Thursday, January 27, 2011

Get datatable

/*text is query */
public DataTable connecttotable(string text)
{
SqlConnection con = GetConnection();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = text;
cmd.Connection = con;
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr); con.Close();
return dt;
}

No comments:

Post a Comment