用SQL怎么改

来源:百度知道 编辑:UC知道 时间:2024/05/30 22:32:31
OleDbConnection con = db.con();
con.Open();
OleDbDataAdapter sdr = new OleDbDataAdapter(" select * from News ", con);
DataSet ds = new DataSet();
sdr.Fill(ds, "News");
GridView1.DataSource = ds.Tables["News"].DefaultView;
这个是从网上下载的,可是他用的是ACCESS+O,我们要求是用SQL Server2000

SqlConnection con = db.con(); //db是另外的对象把,可能需要在它所属的类的con();方法里面也需要改动。
con.Open();
SqlDataAdapter sdr = new SqlDataAdapter(" select * from News ", con);
DataSet ds = new DataSet();
sdr.Fill(ds, "News");
GridView1.DataSource = ds.Tables["News"].DefaultView;

你是不是就是想问C#怎么连接Server2000数据库。