110,546
社区成员
发帖
与我相关
我的任务
分享
string connectString = "Server=(local);Integrated Security=True;Database=northwind";
SqlConnection con = new SqlConnection(connectString);
con .Open();
SqlCommand command = con.CreateCommand();
command.CommandText= "select * from Customers";
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter(command);
adapter.Fill(ds, "Customers");
DataTable t = ds.Tables["Customers"];
//你要添加的行
DataRow r = t.NewRow();
r[0] = *****;
r[1] = ***;
t.Rows.Add(r);
this.dataGridView1.DataSource = t;