求助!
public partial class Form1 : Form
{
SqlConnection cn = new SqlConnection("Data Source=.;Initial Catalog=Student;Integrated Security=True");
SqlCommand command;
SqlDataAdapter adapter;
DataSet ds = new DataSet();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) //查询
{
string sql = "select*from studentinfo";
command = new SqlCommand(sql,cn);
adapter = new SqlDataAdapter(command);
if (ds.Tables["stu"] != null)
{
ds.Tables["stu"].Clear();
}
adapter.Fill(ds, "stu");
dataGridView1.DataSource = ds.Tables["stu"];
}
private void button2_Click(object sender, EventArgs e) //修改
{
SqlCommandBuilder bulider = new SqlCommandBuilder(adapter);
adapter.Update(ds,"stu"); //此处编译不通过
}
}