1

PowerBuilder を初めて使用します。

MSAccess テーブルからデータを取得し、対応する SQL テーブルに更新したいと考えています。同じテーブル情報を持つ別の MSAccess ファイルを選択する必要があるため、MSAccess の永続的な DSN を作成できません。SQL サーバーの永続的な DSN を作成できます。

MSAccess ファイルを選択するときに DSN を動的に作成し、PowerBuilder を使用してすべてのテーブル データを SQL にプッシュする方法を教えてください。

可能であれば、問題を解決するための完全な PowerBuilder コードも提供してください。

4

4 に答える 4

4

In Access we strongly suggest not using DSNs at all as it is one less thing for someone to have to configure and one less thing for the users to screw up. Using DSN-Less Connections You should see if PowerBuilder has a similar option.

于 2009-10-10T02:09:46.160 に答える
1

Tony が参照する DSNless 接続を実行したいと考えています。私はPBDJでそれを行う例を示し、Sybase の CodeXchange にコード サンプルがあります。

于 2009-12-11T02:47:34.457 に答える
1
  • Create the DSN manually in the ODBC administrator
  • Locate the entry in the registry
  • Export the registry syntax into a .reg file
  • Read and edit the .reg file dynamically in PB
  • Write it back to the registry using PB's RegistrySet ( key, valuename, valuetype, value )

Once you've got your DSN set up, there are many options to push data from one database to the other.

You'll need two transaction objects in PB, each pointing to its own database. Then, you could use a Data Pipeline object to manage the actual data transfer.

于 2009-10-08T07:39:46.143 に答える
0

このコードを使用しています。試してみてください。

//// Profile access databases accdb format
SQLCA.DBMS = "OLE DB"
SQLCA.AutoCommit = False
SQLCA.DBParm = "PROVIDER='Microsoft.ACE.OLEDB.12.0',DATASOURCE='C:\databasename.accdb',DelimitIdentifier='No',CommitOnDisconnect='No'"

Connect using SQLCA;
If SQLCA.SQLCode = 0 Then
    Open ( w_rsre_frame )   
else
    MessageBox ("Cannot Connect to Database", SQLCA.SQLErrText )
End If

また

//// Profile access databases mdb format
transaction aTrx
long resu
string database 
database = "C:\databasename.mdb" 
aTrx  = create transaction 
aTrx.DBMS = "OLE DB" 
aTrx.AutoCommit = True 
aTrx.DBParm = "PROVIDER='Microsoft.Jet.OLEDB.4.0',DATASOURCE='"+database+"',PBMaxBlobSize=100000,StaticBind='No',PBNoCatalog='YES'"
connect using aTrx ;
if atrx.sqldbcode = 0 then
    messagebox("","Connection success to database")
else 
    messagebox("Error code: "+string(atrx.sqlcode),atrx.sqlerrtext+ " DB Code Error: "+string(atrx.sqldbcode))
end if
// do stuff...
destroy atrx
于 2013-05-14T22:19:21.307 に答える