求助!
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"); //此处编译不通过
}
}
{
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"); //此处编译不通过
}
}
...全文
相关推荐
求助!如何让数组相加????[财税相关资料系列.txt
求助!如何让数组相加????[财税相关资料系列.txt
目前公开的免疫治疗相关数据集汇总,购买者自行下载,可求助!
目前公开的免疫治疗相关数据集汇总,购买者可自行下载,可求助!
求助!算法!
我是初学者,希望大家多多指教!
求助打印预览的问题!
请帮忙解决,谢谢! 请帮忙解决,谢谢! 请帮忙解决,谢谢! 请帮忙解决,谢谢! 请帮忙解决,谢谢!
求助~高手帮帮小妹吧!
名称:宠物(小动物)店信息管理系统<br>内容:链表的创建、输出、插入、删除、遍历、合并等操作,链表的原始数据可从文件中读取,信息也要求输出到文件中。<br><br>小妹感激不尽!!!!<br>


.NET Framework
