private void btnGetTableList_Click(object sender, EventArgs e) { try { dsDb.Tables["DbTableList"].Rows.Clear(); DataRow dr; DataBaseOperator database = new DataBaseOperator(this.DbcontionStr.Text); SqlDataReader read; string strsql = @"select table_name as tabname from INFORMATION_SCHEMA.TABLES order by table_name"; read = database.ExecuteReader(strsql); while (read.Read()) { dr = dsDb.Tables["DbTableList"].NewRow(); dr["Check"] = false; dr["TableName"] = read["tabname"].ToString(); dsDb.Tables["DbTableList"].Rows.Add(dr); } read.Close(); strsql = @"select b.name as tablename,a.name as colname ,(select top 1 name from sys.types where system_type_id=a.system_type_id) as typename ,(case when is_identity=1 then 'Y' else 'N' end) as _identity ,c.value as remarks from sys.columns a left join sys.objects b on a.object_id=b.object_id left join sys.extended_properties c on a.object_id=c.major_id and a.column_id=c.minor_id where b.type='U' and b.name in (select table_name as tabname from INFORMATION_SCHEMA.TABLES);"; read = database.ExecuteReader(strsql); while (read.Read()) { dr = dsDb.Tables["DbColumnList"].NewRow(); dr["TableName"] = read["tablename"].ToString(); dr["colname"] = read["colname"].ToString(); dr["typename"] = read["typename"].ToString(); dr["_identity"] = read["_identity"].ToString() == "Y" ? true : false; dr["remarks"] = read["remarks"].ToString(); dsDb.Tables["DbColumnList"].Rows.Add(dr); } } catch (Exception err) { MessageBox.Show(err.Message); } }