时间:2021-07-01 10:21:17 帮助过:5人阅读
public ArrayList Table(string database) { cmd.CommandText = "Select TABLE_NAME FROM "+database+".INFORMATION_SCHEMA.TABLES Where TABLE_TYPE=‘BASE TABLE‘ "; conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); string a = null; if (dr.HasRows) { while(dr.Read()) { a = dr["TABLE_NAME"].ToString(); al.Add(a); } } cmd.Dispose(); conn.Close(); return al;
}
public partial class Form2 : Form { private Use UUU; public Form2(Use uuu) { InitializeComponent(); UUU = uuu; } private void Form2_Load(object sender, EventArgs e) { ArrayList aaa = new UserDA(UUU).Table(UUU.Database); for (int y = 0; y < aaa.Count; y++) { comboBox1.Items.Add(aaa[y]); } }
数据库查询Database中的表
标签: