Skip to content

Instantly share code, notes, and snippets.

@talkingdotnet
Created February 26, 2018 08:04
Show Gist options
  • Save talkingdotnet/d843f274aaf749dc0d1704d6e0fba9e9 to your computer and use it in GitHub Desktop.
Save talkingdotnet/d843f274aaf749dc0d1704d6e0fba9e9 to your computer and use it in GitHub Desktop.
private DataTable GetTableList()
{
DataTable dt;
string sQuery = @"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'";
using (SqlConnection conn = new SqlConnection(_connectionString))
{
using (SqlCommand command = new SqlCommand(sQuery, conn))
{
conn.Open();
DataAdapter da = new SqlDataAdapter(command);
DataSet ds = new DataSet();
da.Fill(ds);
dt = ds.Tables[0];
}
}
return dt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment