怎样在一个程序中连接两个数据库
问: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?
- 最新文章
- 自己写 FILTER 改变画面颜色[01-04]
- PowerBuilder 7.0中实现电子邮件的收发[01-04]
- PB数据窗口中按钮的封装[01-04]
- PB5中PFC的使用[01-04]
- 定制PB与SQL Anywhere的程序发布[01-04]
- 怎样在pb中得到存储过程的值[01-04]
- 相关文章
- 如何用pb实现MSACCESS数据库的图片字段存取[01-04]
- 使用PowerBuilder同时访问多个数据库[01-04]
- PowerBuilder与数据库的连接[01-04]
- PowerBuilder数据窗口与数据库[01-04]
- 关于Access数据库程序类型越界[01-04]
- 更改Oracle数据库表的表空间(1)[01-04]
