读书人

C# winform中如何显示使用SQL语句得到

发布时间: 2013-12-19 00:33:34 作者: rapoo

C# winform中怎么显示使用SQL语句得到的结果
我有一段多表查询的语句,怎么在Winform里显示出来
select 字段1,(select子查询),(select子查询),(select子查询),(select子查询) from 表1,表2,表3,表4
where XXX and XXX

[解决办法]


SqlConnection con = new SqlConnection("Server=IP;uid=用户名;pwd=密码;Database=数据库");
con.Open();
string sqlstr = "sql语句";
SqlDataAdapter da = new SqlDataAdapter(sqlstr, con);
DataSet ds= new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
con.Close();

读书人网 >C#

热点推荐