频道直达 - 专题 - 新闻 - 技巧 - 组网 - 开发 - 安全 - web编程 - 图像 - 操作系统 - 数据库 - 教育 - 旅游 - 健康 - 时尚 - 驱动 - 软件 - 游戏 - 多媒体 - ERP - 讨论组

怎样在一个程序中连接两个数据库

来源: 作者: 出处:巧巧读书 2006-09-02 进入讨论组

  问:SOS 怎样在一个程序中连接两个数据库?数据库在两台机器中,一个是SQL6.5,一个是SQL7.0。

答:

你可以这么做
Transaction mytrans1,mytrans2
mytrans1=Create Transaction
mytrans2=Create Transaction
mytrans1.DBMS="驱动程序类型"
mytrans1.DBParm="这里填连接Sql6.5的字串"
mytrans2.DBMS="驱动程序类型"
mytrans1.DBParm="这里填连接Sql7.0的字串"
connect using mytrans1;
connect using mytrans2;
剩下的你知道该怎么做了?

eg:
Transaction mytrans1,mytrans2
mytrans1=Create Transaction
mytrans2=Create Transaction
mytrans1.DBMS = "ODBC"
mytrans1.AutoCommit = False
mytrans1.DBParm = "ConnectString='DSN=YourDsnforSql6.5DB'"
connect using mytrans1;
IF mytrans1.sqlcode = -1 THEN
Messagebox("",Yourmessage)
disconnect using mytrans1;
halt
end if

mytrans2.DBMS = "ODBC"
mytrans2.AutoCommit = False
mytrans2.DBParm = "ConnectString='DSN=YourDsnforSql7.0DB'"
connect using mytrans2;
IF mytrans2.sqlcode = -1 THEN
Messagebox("",Yourmessage)
disconnect using mytrans2;
halt
end if

//If t65 is a table in your sql6.5 Database,t70 is a table in your sql7.0 Database and
//dw_1 and dw_2 are DataWindow Control ,dwo_sql65 and dwo_sql70 are respectedly DataWindow Object
//for t65 and t70 then
dw_1.dataobject="dwo_sql65"
dw_1.settransobject(mytrans1)
dw_1.retrieve()//It is best to test error
dw_2.dataobject="dwo_sql70"
dw_2.settransobject(mytrans2)
dw_2.retrieve()//It's the same as above
//Then ,you can manipulate the data by dw_1 and dw_2
//Do you understand?

静态页面:http://www.qqread.com/pb/e236663.html 更多文章 更多内容请看数据库专栏数据库处理专题城域网专题专题,或进入讨论组讨论。
收藏此文】【 】【打印】【关闭
较早的文章:设置系统时间

较新的文章:使Datawindow每页打印固定行
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
巧巧读书宗旨
相关专题
最新论坛文章
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章