Skip to content

Instantly share code, notes, and snippets.

@belsrc
Created March 17, 2013 00:27
Show Gist options
  • Save belsrc/5178977 to your computer and use it in GitHub Desktop.
Save belsrc/5178977 to your computer and use it in GitHub Desktop.
ADO.Net GetData
private DataTable GetData( string conString, string table ) {
DataTable dt = new DataTable();
using( SqlConnection sqlConn = new SqlConnection( conString ) ) {
sqlConn.Open();
using( SqlCommand sqlCmd = new SqlCommand( "SELECT * FROM " + table, sqlConn ) ) {
using( SqlDataAdapter sqlDa = new SqlDataAdapter( sqlCmd ) ) {
sqlDa.Fill( dt );
}
}
}
return dt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment