请看如下代码:
private IAdapter ada = new SqlAdapter();
private SqlDataAdapter da;
private DataSet ds; private void btShow_Click(object sender, EventArgs e)
{
ds = new DataSet();
da = ada.adapter("SELECT * FROM late");//方法,返回SqlDataAdapter
da.Fill(ds); bindingSource1.DataSource = ds;
bindingNavigator1.BindingSource = bindingSource1;
dataGridView1.DataSource = ds.Tables[0];
} private void toolSave_Click(object sender, EventArgs e)
{
SqlCommandBuilder scb = new SqlCommandBuilder(da);
//ds.AcceptChanges();
da.Update(ds);
}此上代码不报错,但是也不更新数据库?
出了什么问题呢?
private IAdapter ada = new SqlAdapter();
private SqlDataAdapter da;
private DataSet ds; private void btShow_Click(object sender, EventArgs e)
{
ds = new DataSet();
da = ada.adapter("SELECT * FROM late");//方法,返回SqlDataAdapter
da.Fill(ds); bindingSource1.DataSource = ds;
bindingNavigator1.BindingSource = bindingSource1;
dataGridView1.DataSource = ds.Tables[0];
} private void toolSave_Click(object sender, EventArgs e)
{
SqlCommandBuilder scb = new SqlCommandBuilder(da);
//ds.AcceptChanges();
da.Update(ds);
}此上代码不报错,但是也不更新数据库?
出了什么问题呢?
解决方案 »
- asp.net 中如何新建代码隐藏的全局应用程序类文件
- 如何点击 BindingNavigator 的下一条时把数据显示到textbox?
- C#关于https协议webservice访问
- oracle数据库中 如何将date类型变量转换后,赋于为datetime变量
- 内存流MemoryStream是干什么用的,给个简单点的例子好吗?
- log4net多项目调用问题
- 请教~~如何直接向打印机直接输出字符和直线?
- C#很牛的测试题。求高人帮解答。
- 一个从数据库生成树的问题(有BCB的源码。我想转成C#或是vc.net)(MFC的不要)
- 高分求救:C#调用C++的dll,dll的回调函数报错
- datagridviewcomboboxcell 保存值和显示值是怎么实现的
- 求一篇有关计算机的中英文翻译的文章。
private SqlDataAdapter da;
private DataSet ds;private void btShow_Click(object sender, EventArgs e)
{
ds = new DataSet();
da = new SqlDataAdapter("SELECT * FROM late","连接语句");
da.Fill(ds); bindingSource1.DataSource = ds;
bindingNavigator1.BindingSource = bindingSource1;
dataGridView1.DataSource = ds.Tables[0];
}private void toolSave_Click(object sender, EventArgs e)
{
SqlCommandBuilder scb = new SqlCommandBuilder(da);
da.Update(ds);
ds.AcceptChanges();
}
private SqlDataAdapter da;
private DataSet ds; private void btShow_Click(object sender, EventArgs e)
{
ds = new DataSet();
da = ada.adapter("SELECT * FROM late");//方法,返回SqlDataAdapter
SqlCommandBuilder scb = new SqlCommandBuilder(da);
da.Fill(ds); bindingSource1.DataSource = ds;
bindingNavigator1.BindingSource = bindingSource1;
dataGridView1.DataSource = ds.Tables[0];
} private void toolSave_Click(object sender, EventArgs e)
{
//ds.AcceptChanges();
da.Update(ds);
}
toolSave是bindingNavigator上面的按扭,自已添加的
经过半夜奋战,问题就发生在这儿,如果是个单独的按纽则所有LS的代码均没有问题~http://blog.csdn.net/hwj383/archive/2008/05/08/2414935.aspx