you should try something like this to get the table schema.
public partial class Form1 : Form
{
const string conString = @"Data Source=.\SQLEXPRESS; Initial Catalog=DBTest; Integrated Security=SSPI";
SqlConnection cn = null;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.getTableSchema();
}
private void getTableSchema()
{
try
{
cn = new SqlConnection(conString);
cn.Open();
DataTable dt = cn.GetSchema("tables");
this.dataGridView1.DataSource = dt;
}
catch (Exception)
{
throw;
}
}
}
EDIT: close quote from conString
source
share