本人对数据库是菜鸟
最近要用到
C# 操作ACCESS 本地数据库问题 insert 成功 update 失败
try
{
this.custom_simpleTableAdapter.Insert(data_custom_simple_new.客户号,data_custom_simple_new.客户名称,
data_custom_simple_new.当前权益,data_custom_simple_new.最高权益,data_custom_simple_new.最低权益,
data_custom_simple_new.交易开始日期,data_custom_simple_new.数据更新日期,data_custom_simple_new.最近交易日期);
this.custom_simpleTableAdapter.Fill(this.futuresTradeDataSet.custom_simple);
}
catch (System.Exception ex)
{
this.richTextBox2.Text = ex.Message + "\n" + this.richTextBox2.Text;
}
insert 代码如上,成功没有问题 form中有一个dataGridView 绑定数据库 custom_simple 为数据库中的一个表update 老是不成功 update 返回0 没有exception抛出 update代码DataRow newrow = this.futuresTradeDataSet.custom_simple.NewRow();//.Tables[0].NewRow();
newrow["编号"] = data_custom_simple_new.编号;
newrow["客户号"] = data_custom_simple_new.客户号;
newrow["客户名称"] = data_custom_simple_new.客户名称;
newrow["当前权益"] = data_custom_simple_new.当前权益;
newrow["最高权益"] = data_custom_simple_new.最高权益;
newrow["最低权益"] = data_custom_simple_new.最低权益;
newrow["交易开始日期"] = data_custom_simple_new.交易开始日期.Date.ToLongDateString();
newrow["数据更新日期"] = data_custom_simple_new.数据更新日期.Date.ToLongDateString();
newrow["最近交易日期"] = data_custom_simple_new.最近交易日期.Date.ToLongDateString();
int retint = this.custom_simpleTableAdapter.Update(newrow);
this.custom_simpleTableAdapter.Fill(this.futuresTradeDataSet.custom_simple);
另外用update的另一个方法也不能成功update 代码如下int retint= this.custom_simpleTableAdapter.Update(data_custom_simple_new.客户号,
data_custom_simple_new.客户名称,
data_custom_simple_new.当前权益,
data_custom_simple_new.最高权益,
data_custom_simple_new.最低权益,
data_custom_simple_new.交易开始日期,
data_custom_simple_new.数据更新日期,
data_custom_simple_new.最近交易日期,
int.Parse(data_custom_simple_old.编号.ToString()), data_custom_simple_old.客户号,
data_custom_simple_old.客户名称,
data_custom_simple_old.当前权益,
data_custom_simple_old.最高权益,
data_custom_simple_old.最低权益,
data_custom_simple_old.交易开始日期,
data_custom_simple_old.数据更新日期,
data_custom_simple_old.最近交易日期);*/
this.custom_simpleTableAdapter.Fill(this.futuresTradeDataSet.custom_simple);
分不多 大拿们帮下忙
最近要用到
C# 操作ACCESS 本地数据库问题 insert 成功 update 失败
try
{
this.custom_simpleTableAdapter.Insert(data_custom_simple_new.客户号,data_custom_simple_new.客户名称,
data_custom_simple_new.当前权益,data_custom_simple_new.最高权益,data_custom_simple_new.最低权益,
data_custom_simple_new.交易开始日期,data_custom_simple_new.数据更新日期,data_custom_simple_new.最近交易日期);
this.custom_simpleTableAdapter.Fill(this.futuresTradeDataSet.custom_simple);
}
catch (System.Exception ex)
{
this.richTextBox2.Text = ex.Message + "\n" + this.richTextBox2.Text;
}
insert 代码如上,成功没有问题 form中有一个dataGridView 绑定数据库 custom_simple 为数据库中的一个表update 老是不成功 update 返回0 没有exception抛出 update代码DataRow newrow = this.futuresTradeDataSet.custom_simple.NewRow();//.Tables[0].NewRow();
newrow["编号"] = data_custom_simple_new.编号;
newrow["客户号"] = data_custom_simple_new.客户号;
newrow["客户名称"] = data_custom_simple_new.客户名称;
newrow["当前权益"] = data_custom_simple_new.当前权益;
newrow["最高权益"] = data_custom_simple_new.最高权益;
newrow["最低权益"] = data_custom_simple_new.最低权益;
newrow["交易开始日期"] = data_custom_simple_new.交易开始日期.Date.ToLongDateString();
newrow["数据更新日期"] = data_custom_simple_new.数据更新日期.Date.ToLongDateString();
newrow["最近交易日期"] = data_custom_simple_new.最近交易日期.Date.ToLongDateString();
int retint = this.custom_simpleTableAdapter.Update(newrow);
this.custom_simpleTableAdapter.Fill(this.futuresTradeDataSet.custom_simple);
另外用update的另一个方法也不能成功update 代码如下int retint= this.custom_simpleTableAdapter.Update(data_custom_simple_new.客户号,
data_custom_simple_new.客户名称,
data_custom_simple_new.当前权益,
data_custom_simple_new.最高权益,
data_custom_simple_new.最低权益,
data_custom_simple_new.交易开始日期,
data_custom_simple_new.数据更新日期,
data_custom_simple_new.最近交易日期,
int.Parse(data_custom_simple_old.编号.ToString()), data_custom_simple_old.客户号,
data_custom_simple_old.客户名称,
data_custom_simple_old.当前权益,
data_custom_simple_old.最高权益,
data_custom_simple_old.最低权益,
data_custom_simple_old.交易开始日期,
data_custom_simple_old.数据更新日期,
data_custom_simple_old.最近交易日期);*/
this.custom_simpleTableAdapter.Fill(this.futuresTradeDataSet.custom_simple);
分不多 大拿们帮下忙
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货