C#高手进来一下,C#windowsForms中的DataGridView显示出了问题
我用DataGridView绑定了数据源,我把代码放到Button_click里就能显示数据,放到dataGridView1_CellContentClick事件里就显示...
我用DataGridView绑定了数据源,我把代码放到Button_click里就能显示数据,放到dataGridView1_CellContentClick事件里就显示不出来,代码如下:
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "data source =(local) ;Database = 学生信息表; user id = sa;password = 123";
conn.Open();
string strCmd;
strCmd = "select * from table1";
SqlDataAdapter myDataAdapter;
DataSet myDataSet = new DataSet();
myDataAdapter = new SqlDataAdapter(strCmd, conn);
myDataAdapter.Fill(myDataSet, "table1");
dataGridView1.DataSource = myDataSet.Tables["table1"]; 展开
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "data source =(local) ;Database = 学生信息表; user id = sa;password = 123";
conn.Open();
string strCmd;
strCmd = "select * from table1";
SqlDataAdapter myDataAdapter;
DataSet myDataSet = new DataSet();
myDataAdapter = new SqlDataAdapter(strCmd, conn);
myDataAdapter.Fill(myDataSet, "table1");
dataGridView1.DataSource = myDataSet.Tables["table1"]; 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询