首页 > 题库 > 学历提升 > 自学考试 > 自考本科 > 填空题

将下列事件程序补充完整,使得程序运行后,打开Form1窗体,jxgl数据库中xs表的数据显示在DataGridView控件中。DataGridView控件的name属性值为dgv。
private void Form1_Load(object sender, EventArgs e)
{
       SqlConnection conn =new SqlConnection();
       conn. ConnectionStringstr="Data Source =(local);Initial Catalog=jxgl;
               Integrated Security=SSPI ";
                     ;                                   //  (1)打开数据库连接
       string sql="select * from xs";
       SqICommandcomm= new Sqlcommand(sql, conn);
       da.SelectCommand=comm;
       SqlCommandBuilder builder= new SqlCommandBuilder(da);
       da.Fill(ds,"xs");
                              = ds.Tables["xs"]; //  (2)将数据表绑定到DataGridView控件
       conn. Close();
}


参考答案: 查看答案 查看解析 下载APP畅快刷题

相关知识点试题

相关试卷