37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using ServerExplorer.Code.DataTransfer;
|
|
|
|
namespace ServerExplorer.Code.DataAccess
|
|
{
|
|
public class TableDA
|
|
{
|
|
public static List<Table> Table_GetRegs(string conexionString)
|
|
{
|
|
var tables = new List<Table>();
|
|
var cnx = new SqlConnection(conexionString);
|
|
|
|
cnx.Open();
|
|
DataTable dt = cnx.GetSchema("Tables");
|
|
cnx.Close();
|
|
dt.DefaultView.Sort = "TABLE_SCHEMA ASC, TABLE_NAME ASC, TABLE_TYPE ASC";
|
|
dt = dt.DefaultView.ToTable();
|
|
|
|
// Mostrar todas las tablas
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
tables.Add(new Table
|
|
{
|
|
Schema = (string)dr["TABLE_SCHEMA"],
|
|
Name = (string)dr["TABLE_NAME"],
|
|
Type = (string)dr["TABLE_TYPE"]
|
|
});
|
|
}
|
|
|
|
return tables;
|
|
}
|
|
}
|
|
}
|