发新话题
打印

[数据库] 客户端与服务器之间的数据库更新传输问题!

客户端与服务器之间的数据库更新传输问题!

我的问题:
     客户端与服务器的数据库结构是一样的,我的目的是把客户端的新数据上传到服务器的对应表中,把服务器在客户端中没有的记录下载到客户端的对表中。以下是我的小段代码:
    '连结客户端数据库
    Adodc1.ConnectionString = con
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = "select * from gas_station order by gas_station_id ASC"
    Adodc1.Refresh
    '连结服务器数据库
    Adodc2.ConnectionString = rsSQL
    Adodc2.CommandType = adCmdText
    Adodc2.RecordSource = "select * from gas_station order by gas_station_id ASC"
    Adodc2.Refresh
   
    '下载数据到客户端
    Adodc1.Recordset.AddNew ' 判断空值         
    Adodc1.Recordset("gas_station_id") = Adodc2.Recordset("gas_station_id")
    If VarType(Adodc2.Recordset("gas_station_name")) = vbNull Then
       Adodc1.Recordset("gas_station_name") = Null
    Else
      Adodc1.Recordset("gas_station_name") = Adodc2.Recordset("gas_station_name")
    End If
   .....
    Adodc1.Recordset.UpdateBatch adAffectAllChapters
    Adodc1.Refresh
   
    '向服务器提交新记录
    Adodc1.ConnectionString = rsSQL
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = "select * from member_bargaining"
    Adodc1.Refresh
   
    Adodc2.ConnectionString = conn
    Adodc2.CommandType = adCmdText
    Adodc2.RecordSource = "select * from member_bargaining where state=0 order by user_id,id ASC"
    Adodc2.Refresh
    Adodc1.Recordset.AddNew ' 判断空值
    If VarType(Adodc3.Recordset("gas_station_id")) = vbNull Then
       Adodc1.Recordset("gas_station_id") = Null
    Else
      Adodc1.Recordset("gas_station_id") = Adodc3.Recordset("gas_station_id")
    End If
    ......
    Adodc1.Recordset.UpdateBatch adAffectAllChapters
    Adodc1.Refresh

-----------------------------------------------
   1、这样子的上传下载的速度很慢!
   2、有的时候出现重复数据
   3、到后来数据有时候都传不动了
请问大家,我这种传输方式是不是不理想的一种传输方式呀?我这里是通过循环一条条增加的,有没有一种更的好的方法呀?你们是采用什么方式来实现客户端与服务器之间的数据库交换数据的?
    谢谢大家!小弟我急用!请有经验的高手给我提供点帮助!

TOP

帮忙给看一下!谢谢各位。。。

TOP

是不理想的传输方式,客户端直接访问服务器端的数据库是很不安全的,也不稳定的。

建议你采用通过服务器端程序来访问数据库,客户端只连接服务器端的程序,连接后,服务器端通过数据库还给客户端数据。

数据结构可以使用XML。
换个头像,看见广告就眼红,直接封ID。

TOP

是不是把服务的新数据转成XML,然后传到客户端,在客户再来读取XML文件吗?这样不是要三个过程吗?

TOP

给点意见吧!

TOP

XML方式确实不错
换个头像,看见广告就眼红,直接封ID。

TOP

发新话题