public void show()
{
ds = new DataSet();
ada = new SqlDataAdapter("select * from sys.tables", conn);
//ada = new SqlDataAdapter("select * from emp", conn);
//ds = new DataSet();
ada.Fill(ds);
}
private void Form1_Load(object sender, EventArgs e)
{
conn = new SqlConnection(@"Data Source=ASHISH-PC\SQLEXPRESS; initial catalog=ashish; integrated security=true");
show();
foreach (DataTable dt in ds.Tables)
{
comboBox1.Items.Add(dt.TableName[0]);
}
}
答案 0 :(得分:0)
我猜你只是在寻找快速而又脏的东西。目前,您将返回DataTable对象的名称。你需要这样的东西:
foreach (DataTable dt in ds.Tables)
{
foreach (DataRow dr in dt.Rows)
{
comboBox1.Items.Add(dr[0].ToString());
}
}
就像我说的那样,又快又脏。