private void Form1_Load(object sender, EventArgs e)
{
conn = new SqlConnection(@"Data Source=ASHISH-PC\SQLEXPRESS; initial catalog=ashish; integrated security=true");
show();
foreach (DataT开发者_JAVA百科able dt in ds.Tables)
{
comboBox1.Items.Add(dt.TableName[0]);
}
}
http://msdn.microsoft.com/en-us/library/ms254934(VS.80).aspx
This will give you information on the GetSchema() method which does what you want.
Also googling for GetSchema will get plenty of results which should show you how to get the tables in a database.
there is a library called SMO i havent used but i guess you can do this using SMO. It does not depend on your DataTable directly retrieving table names from sql server. I changed the link below the newer is better http://msdn.microsoft.com/en-us/library/ms162185.aspx
精彩评论