string strconn = " provider=Microsoft.Jet.OLEDB.4.0;Data Source=hotel.mdb" ;
OleDbConnection myconn = new OleDbConnection (strconn) ;
string strHY="select 会员号 from 客户信息表 where 房号='";
strHY+=comboBox1.Text+"'";
DataSet dsHY=new DataSet();
myconn.Open();
OleDbDataAdapter daHY=new OleDbDataAdapter(strHY,myconn);
daHY.Fill(dsHY,"客户信息表");
string HY=dsHY.Tables["客户信息表"].Rows[0]["会员号"].ToString();
string huiyuanbiao="select 住店次数,消费金额 from 会员表 where 会员号='";
huiyuanbiao+=HY+"'";
OleDbDataAdapter DAHY=new OleDbDataAdapter(huiyuanbiao,myconn);
DAHY.Fill(dsHY,"会员表");
int cishu1=Convert.ToInt32(dsHY.Tables["会员表"].Rows[0]["住店次数"]);
int jinE1=Convert.ToInt32(dsHY.Tables["会员表"].Rows[0]["消费金额"]);
int cishu=cishu1+1;
int jinE=jinE1+Convert.ToInt32(textBox7.Text); if(HY=="")
{
MessageBox.Show("非会员");
}
else
{
string InsertHuiyuan="UPDATE 会员表 set 住店次数=";
InsertHuiyuan+=cishu+"and 消费金额=";
InsertHuiyuan+=jinE+" where 会员号='";
InsertHuiyuan+=HY+"'";
OleDbCommand inst2=new OleDbCommand( InsertHuiyuan,myconn);
inst2.ExecuteNonQuery () ;
}
myconn.Close();
上面是代码,为什么数据表总是更新不了呢?
调试没错误,就是不更新.
谢谢了?
解决方案 »
- winhttp.dll组件使用System.Type.InvokeMembe方式r如何设置option属性?
- 今天公司内部.net基础测试……在线等结果1
- 怎么把dateset里面的数据 赋给一个string数组呢
- 如何获取可用的盘符?
- 已知SqlServer2000的表名,如何得到创建该表的SQL脚本?
- 郁闷~~~~关于事务,高手请进哦
- 实现在一个时间范围内,lable给出一个提示信息
- dataset.merge()的实际含义是什么?
- WPF,如何不共享资源实例
- 再问一遍:解决后马上结帖!我不信CSDN上没有能解决!!!
- 怎么获取time.nist.gov服务器的系统啊
- .NET GridView自动套用格式与编辑列的问题
InsertHuiyuan+=cishu+" and 消费金额=";
//update中的set中的条件用逗号分隔
InsertHuiyuan+=cishu+" , 消费金额=";
OleDbConnection myconn = new OleDbConnection (strconn) ;
string strHY="select 会员号 from 客户信息表 where 房号='";
strHY+=comboBox1.Text+"'";
DataSet dsHY=new DataSet();
myconn.Open();
OleDbDataAdapter daHY=new OleDbDataAdapter(strHY,myconn);
daHY.Fill(dsHY,"客户信息表");
string HY=dsHY.Tables["客户信息表"].Rows[0]["会员号"].ToString();
string huiyuanbiao="select 住店次数,消费金额 from 会员表 where 会员号='";
huiyuanbiao+=HY+"'";
OleDbDataAdapter DAHY=new OleDbDataAdapter(huiyuanbiao,myconn);
DAHY.Fill(dsHY,"会员表");
int cishu1=Convert.ToInt32(dsHY.Tables["会员表"].Rows[0]["住店次数"]);
int jinE1=Convert.ToInt32(dsHY.Tables["会员表"].Rows[0]["消费金额"]);
int cishu=cishu1+1;
int jinE=jinE1+Convert.ToInt32(textBox7.Text); if(HY=="")
{
MessageBox.Show("非会员");
}
else
{
string InsertHuiyuan="UPDATE 会员表 set 住店次数= ";
InsertHuiyuan+=cishu+" , 消费金额=";
InsertHuiyuan+=jinE+" where 会员号='";
InsertHuiyuan+=HY+"'";
OleDbCommand inst2=new OleDbCommand( InsertHuiyuan,myconn);
inst2.ExecuteNonQuery () ;
}
myconn.Close();