Created
March 17, 2013 00:27
-
-
Save belsrc/5178977 to your computer and use it in GitHub Desktop.
ADO.Net GetData
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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