SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=Northwind;Integrated Security=True;Persist Security Info=True");
SqlCommand cmd = new SqlCommand("select * from Employees",con);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
con.Open();//打开数据库连接
DataSet ds = new DataSet();
sda.Fill(ds, "Employees");//用Employees表填充数据集
con.Close();//关闭数据库连接
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
老说我编译出错,哪错了啊?谢谢
SqlCommand cmd = new SqlCommand("select * from Employees",con);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
con.Open();//打开数据库连接
DataSet ds = new DataSet();
sda.Fill(ds, "Employees");//用Employees表填充数据集
con.Close();//关闭数据库连接
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
老说我编译出错,哪错了啊?谢谢
DataSet ds = new DataSet();
sda.Fill(ds, "Employees");//用Employees表填充数据集
this.GridView1.DataSource = ds;
this.GridView1.DataBind();就行了。
但搞笑的是,我把Employees的双引号重新敲下,又能编译了