當前位置:首頁 » 數據倉庫 » pb連接兩個資料庫連接
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

pb連接兩個資料庫連接

發布時間: 2022-06-04 01:57:42

『壹』 PB 如何同時連接兩個sql資料庫

Transaction mydb
mydb.DBMS = "O84 Oracle8/8i (8.x.4+)"
mydb.LogPass =""
mydb.ServerName = "fdztrun"
mydb.LogId = "system"
mydb.AutoCommit = False
connect using mydb;
select * from table using mydb;

『貳』 pb9中如何管理兩個資料庫連接

pb每連接一個資料庫用一個事務對象
平常我們所用的sqlca就是默認的事務對象
你可以定義多個事務對象transaction
例如transaction
mytran
你再設置一下連接參數,就像設置sqlca的連接參數一樣,
最後連接,當然,是用connect
using
mytran;
如果不加後面的using
mytran,系統默認用sqlca連接
這樣就連接上另外一個資料庫了,你還可以再定義幾個,
這樣當你操作不同的資料庫(sql代碼)時,你就在後面加上一個(using
事務對象名)
而數據窗口就在settransobject()這步設置
你可以試試

『叄』 pb如何連接access資料庫

在主程序 open事件中鍵入如下語句,即可連接資料庫:
sqlca.DBMS='ODBC'
sqlca.DbParm="ConnectString='DBQ=database.mdb;PWD=123456;DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};'"
Connect using sqlca;
If sqlca.sqlcode <> 0 Then
MessageBox("",sqlca.sqlerrtext)
Return
End If

『肆』 pb 9.0中到底怎麼連接資料庫

在powerbuilder軟體界面,點擊上面資料庫圖標。

2
彈出Database Profiles窗口,在此窗口內,雙擊圖中標注ODBC Administrator項。

3
在彈出的ODBC數據源管理器中點擊右側的添加按鈕。

在彈出的創建新數據源窗口中,點擊最下方SQL Server Native Client 10.0項。

彈出創建到SQL Server的新數據源窗口,輸入任意名稱、描述,伺服器處輸入(local),點擊下一步。

在新的界面最上方「更改默認資料庫為」前勾選,下方選擇你的程序想要連接的資料庫。點擊下一步。

一直點擊下一步直到如圖界面,到此數據源的添加基本完成,點擊下方測試數據源,提示成功後關閉此界面即可;如果不成功請從頭再次操作,注意每一個小細節。

上個步驟關閉窗口後,回到原來的ODBC數據源管理器窗口,可以看到列表上方出現了剛剛創建的數據源,關閉此窗口。

回到Database Profiles窗口,如圖,點擊ODB ODBC,然後點擊右側New按鈕。

新彈出Database Profile Setup-ODBC窗口,填寫Profile Name,下拉列表選擇對應Data Source項。(如果你的資料庫沒有設置登錄密碼,則下方的user id和password項不需填寫)

中間穿插一步,如圖,在這個窗口上方點擊Preview標簽,復制下方的一段代碼,留待後面使用。
點擊OK,關閉此窗口。

點擊新添加的那一項,如圖,點擊右側Connect按鈕,然後資料庫小圖標會出現一個綠色小勾。到這里,連接資料庫的所有配置已經完成,只需在程序中添加連接資料庫的代碼就可以了。

如圖,我在我的一個程序窗口的open事件中添加了剛剛復制的那段代碼,這樣這個窗口在打開時就可以直接連上資料庫了。

『伍』 PB連接兩個access資料庫,提示database transaction information not available

PB中的數據窗在Retrieve之前要使用SetTransObject()函數的,因為該函數是指定數據窗使用哪個事務(一個每連接一個資料庫就是一個單獨的事務,當一個實例下多個資料庫時,就需要定義多個實例),要不然PB怎麼知道去連接哪個資料庫呢?~從你的報錯情況來看,是你的事務不可用,也就是定義錯誤了,在DataBase Profile下有一個PreView選項,裡面就是定義連接到資料庫的事務,可以拷出來,放在打開主窗口的Open事件中,就可以了

『陸』 在pb里可以同時連接兩個資料庫么

可以的,PB中同時連接多個資料庫,如連接SQLServer2000和Oracle8 ,代碼如下:
string ls_startupfile
ls_startupfile='hisini.ini'
sqlca.DBMS = ProfileString(ls_startupfile, "database", "dbms", "")
sqlca.database = ProfileString(ls_startupfile, "database", "database", "")
sqlca.userid = ProfileString(ls_startupfile, "database", "userid", "")
sqlca.dbpass = ProfileString(ls_startupfile, "database", "dbpass", "")
sqlca.logid = ProfileString(ls_startupfile, "database", "logid", "")
sqlca.logpass = ProfileString(ls_startupfile, "database", "LogPassWord", "")
sqlca.servername = ProfileString(ls_startupfile, "database", "servername", "")
sqlca.dbparm = ProfileString(ls_startupfile, "database", "dbparm", "")
remote_trans= CREATE transaction
remote_trans.DBMS = ProfileString(ls_startupfile, "Database_remote", "dbms", "")
remote_trans.database = ProfileString(ls_startupfile, "Database_remote", "database", "")
remote_trans.userid = ProfileString(ls_startupfile, "database_remote", "userid", "")
remote_trans.dbpass = ProfileString(ls_startupfile, "database_remote", "dbpass", "")
remote_trans.logid = ProfileString(ls_startupfile, "database_remote", "logid", "")
remote_trans.logpass = ProfileString(ls_startupfile, "database_remote", "LogPassWord", "")
remote_trans.servername = ProfileString(ls_startupfile, "database_remote", "servername", "")
remote_trans.dbparm = ProfileString(ls_startupfile, "database_remote", "dbparm", "")
//附hisini.ini
[Database]
DBMS=MSS Microsoft SQL Server 6.x
Database=his
UserId=
DatabasePassword=
ServerName=.
LogId=sa
Lock=
Prompt=0
computer='11'
ocx= 0
use0='之住院管理'
cfprint='1'
[Database_remote]
DBMS = "O84 Oracle8/8i(8.x.4+)"
ServerName = "oracle8"
LogId = "dba"
Database=zx
UserId=
DatabasePassword=
Lock=
Prompt=0
computer='11'
ocx= 0
cfprint='1'

『柒』 PB設計登錄窗口時,怎麼和資料庫連接起來

你可以在整個窗口的open事件中把資料庫連接參數寫好,然後connect using sqlca;或者類似。
然後再登陸按鈕的時候就可以用了。
或者直接在登陸按鈕中寫資料庫連接參數,然後connect。