新建一个winformAPP 放一个gridControl 为gridC 再放一个button 用法与dataGrid一样
代码如下:
/// <summary> /// 显示数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=123;database=test")) { using (SqlDataAdapter ada = new SqlDataAdapter("select * from users ", con)) { DataTable dt = new DataTable(); ada.Fill(dt); grdC.DataSource = dt; } } }
原文地址:https://www.cnblogs.com/SoftWareIe/p/8808209.html
时间: 2024-10-03 07:55:46