Created
February 25, 2018 15:35
-
-
Save talkingdotnet/6b500ec39dc074dc360b369b024e3464 to your computer and use it in GitHub Desktop.
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 FetchData(string tableName) | |
{ | |
using (SqlConnection conn = new SqlConnection(_connectionString)) | |
{ | |
string sQuery = "SELECT * FROM [" + tableName + "]"; | |
using (SqlCommand command = new SqlCommand(sQuery, conn)) | |
{ | |
conn.Open(); | |
command.CommandTimeout = 180; | |
DataAdapter da = new SqlDataAdapter(command); | |
DataSet ds = new DataSet(); | |
da.Fill(ds); | |
DataTable dt = ds.Tables[0]; | |
dt.TableName = tableName; | |
ds.Tables.Remove(dt); | |
return dt; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment