关系表报错
我想对 CARD-USAGE-ONLINE表 删除同步,更新同步 应该怎么做
我是个初学者,能不能给代码。
问题好久了,有点急。望知道的老师,帮助下,谢谢了。谢谢大家。
我自己在谷歌上和CSDN上,都找过了。没有找到想要的答案。55555555
我想对 CARD-USAGE-ONLINE表 删除同步,更新同步 应该怎么做
我是个初学者,能不能给代码。
问题好久了,有点急。望知道的老师,帮助下,谢谢了。谢谢大家。
我自己在谷歌上和CSDN上,都找过了。没有找到想要的答案。55555555
解决方案 »
- 有用过TransactionScope的吗?能说明下为什么事务不回滚吗?
- 我给出我所有的积分,只要能解决我的问题! C#遍历属性时,如何取得此(子)属性的引用
- 如何添加ToolBar,非诚勿扰!
- 执行c#的.exe文件报应用程序正常初始化(0xc0000135)失败
- UDP通讯问题
- 怎样设置datagridview的列宽?手动绑定的
- winform利用DataGrid更新数据库的问题
- SaveFileDialog窗体返回DialogResult值错误!
- 关于继承中方法重写的问题。
- 请问我想先跳出一个对话框(只有确定铵钮),后转向另一个页面,我要怎么写呀?/
- datagridview怎样实现选定一行时某一列自动处于编辑状态(就是有光标闪),如果有数据则数据处于选中状态.
- 如何在网页上动态对checkboxlist添加选项?
TRANSFER表中没有数据
只对CARD-USAGE-ONLINE表 删除同步,更新同步
5555555555555
oleCon1.Open();
string ls_id = "0";
while(i<n)
{
ls_id = "0";
OleDbDataAdapter oleDap1 = new OleDbDataAdapter("insert into card(code,cardtype,kind,owndate,idkind,name,sex,birthdate,address,country,state,hoststate,membercode,keyword,gradeid,contact,profession,balance,consumed,limit) values('" + wangdunlist[i]+ "',0,1,'0:00:00',11,'等待验证…',1,'0:00:00','-','未知',0,'00000','" + wangdunlist[i] + "','11',0,'-','-',0,0,0)", oleCon1);
DataSet ds1 = new DataSet();
oleDap1.Fill(ds1, "card");
ds1.Dispose();
oleDap1.Dispose();
OleDbDataAdapter oleDap2 = new OleDbDataAdapter("select * from card", oleCon1);
DataSet ds2 = new DataSet();
oleDap2.Fill(ds2, "card");
ls_id = ds2.Tables[0].Rows[i][0].ToString();
ds2.Dispose();
oleDap2.Dispose();
oleCon1.Close();
oleCon1.Open();
OleDbDataAdapter oleDap3 = new OleDbDataAdapter("insert into usage(cardid,price,charge,times,starttime,endtime,state,grade) values(" + ls_id + " ,0,0,0,'" + maskedTextBox1.Text + "','" + maskedTextBox1.Text + "',1,0)", oleCon1);
DataSet ds3 = new DataSet();//为什么会在这里报错那 。前一个都成功了
oleDap3.Fill(ds3, "usage");
ds3.Dispose();
oleDap3.Dispose();
ls_id="0";
OleDbDataAdapter oleDap4 = new OleDbDataAdapter("select * from usage", oleCon1);
DataSet ds4 = new DataSet();
oleDap4.Fill(ds4, "usage");
ls_id = ds4.Tables[0].Rows[i][0].ToString();
ds4.Dispose();
oleDap4.Dispose(); OleDbDataAdapter oleDap5 = new OleDbDataAdapter("insert into online(uaageid,terminalid,STARTTIME,TIMEFLAG,innerip,state) values(" + ls_id+ " ," + wangdunlid[i] + ",'" + maskedTextBox1.Text + "','" + maskedTextBox1.Text + "','" + wangdunlip[i] + "',1)", oleCon1);
DataSet ds5 = new DataSet();
oleDap5.Fill(ds5, "online");
ds5.Dispose();
oleDap5.Dispose();
i = i + 1; }
老实说完全么看懂代码,LZ应该多看几本书弄清楚DataAdapter和DataSet都是啥。
我查了下。
好多地方看不懂。还是不知道怎么用!
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Security.Cryptography;
using System.Data.OleDb;namespace text
{ public partial class Form1 : Form
{
public string strPath = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:DataBase Password='ddccnn';User Id=admin;Data source=" + Application.StartupPath + "\\bar2003.mdb";//加入的数据库
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
//这个代码只插入一条语句的事例
OleDbConnection oleCon1 = new OleDbConnection(strPath);
string ls_id = "0";
// 向CARD表插入数据
OleDbDataAdapter oleDap1 = new OleDbDataAdapter("insert into card(code,cardtype,kind,owndate,idkind,name,sex,birthdate,address,country,state,hoststate,membercode,keyword,gradeid,contact,profession,balance,consumed,limit) values('0012319197',0,1,'0:00:00',11,'等待验证…',1,'0:00:00','-','未知',0,'00000','0012319197','11',0,'-','-',0,0,0)", oleCon1);
DataSet ds1 = new DataSet();
oleDap1.Fill(ds1, "card");
ds1.Dispose();
oleDap1.Dispose();
//获取card表刚加入的ID
OleDbDataAdapter oleDap2 = new OleDbDataAdapter("select * from card", oleCon1);
DataSet ds2 = new DataSet();
oleDap2.Fill(ds2, "card");
ls_id = ds2.Tables[0].Rows[0][0].ToString();
ds2.Dispose();
oleDap2.Dispose();
oleCon1.Close();
oleCon1.Open();
//向USAGE表插入数据
OleDbDataAdapter oleDap3 = new OleDbDataAdapter("insert into usage(cardid,price,charge,times,starttime,endtime,state,grade) values(" + ls_id + " ,0,0,0,'2008-02-06 12:23:56',''2008-02-06 12:23:56',1,0)", oleCon1);
DataSet ds3 = new DataSet();
oleDap3.Fill(ds3, "usage");
ds3.Dispose();
oleDap3.Dispose();
ls_id="0";
//获得USAGE表刚加入的ID
OleDbDataAdapter oleDap4 = new OleDbDataAdapter("select * from usage", oleCon1);
DataSet ds4 = new DataSet();
oleDap4.Fill(ds4, "usage");
ls_id = ds4.Tables[0].Rows[0][0].ToString();
ds4.Dispose();
oleDap4.Dispose();
//向ONLInE表插入数据
OleDbDataAdapter oleDap5 = new OleDbDataAdapter("insert into online(uaageid,terminalid,STARTTIME,TIMEFLAG,innerip,state) values(" + ls_id + " ,21,'2008-02-06 12:23:56','2008-02-06 12:23:56','192.168.1.6',1)", oleCon1);//这里的terminalid 和innerip 取自TERMINAL表
DataSet ds5 = new DataSet();
oleDap5.Fill(ds5, "online");
ds5.Dispose();
oleDap5.Dispose();
} private void button2_Click(object sender, EventArgs e)
{
OleDbConnection oleCon1 = new OleDbConnection(strPath);
oleCon1.Open();
OleDbDataAdapter oleDap1 = new OleDbDataAdapter("delete from card", oleCon1);//删除数据库数据
DataSet ds1 = new DataSet();
oleDap1.Fill(ds1, "card");
oleCon1.Close();
oleCon1.Dispose();
} private void Form1_Load(object sender, EventArgs e)
{ }
}
}
或者我把数据库发给你。
是#2008-XX-XX#
不是'2008-XX-XX'
:)