Skip to content

Instantly share code, notes, and snippets.

@lethern
Created November 17, 2019 16:46
Show Gist options
  • Save lethern/89aba870db64413220bf0cfd8d1f6bd9 to your computer and use it in GitHub Desktop.
Save lethern/89aba870db64413220bf0cfd8d1f6bd9 to your computer and use it in GitHub Desktop.
public object getTablesSchema(int a)
{
using (SqlConnection conn = getConnection(""))
return getTablesSchema_impl(conn);
}
public object getTablesSchema_customDB(string db_name)
{
try {
using (SqlConnection conn = getConnection_custom(db_name))
return getTablesSchema_impl(conn);
}
catch (Exception e) {
throw;
}
}
private object getTablesSchema_impl(SqlConnection conn)
{
using (SqlCommand command = new SqlCommand("", conn))
{
conn.Open();
command.CommandText = "SELECT table_name" +
" FROM INFORMATION_SCHEMA.TABLES" +
" order by table_name";
return UtilsDB.getResults_ext(command);
}
}
public static List<string> getResults_listSingleStr(SqlCommand command)
{
using (SqlDataReader reader = command.ExecuteReader())
{
return getResults_listSingleStr_impl(reader);
}
}
private static List<string> getResults_listSingleStr_impl(SqlDataReader reader)
{
List<string> result = new List<string>();
while (reader.Read())
{
result.Add(dbObjToStr(reader.GetValue(0)));
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment