[英]PowerBuilder DSN Creation
I am new to PowerBuilder. 我是PowerBuilder的新手。
I want to retrieve the data from MSAccess tables and update it to corresponding SQL tables. 我想从MSAccess表中检索数据并将其更新为相应的SQL表。 I am not able to create a permanent DSN for MSAccess because I have to select different MSAccess files with same table information.
我无法为MSAccess创建永久的DSN,因为我必须选择具有相同表信息的不同MSAccess文件。 I can create a permanent DSN for SQL server.
我可以为SQL Server创建永久的DSN。
Please help me to create DSN dynamically when selecting the MSAccess file and push all the tables data to SQL using PowerBuilder. 选择MSAccess文件时,请帮助我动态创建DSN,并使用PowerBuilder将所有表数据推入SQL。
Also give the full PowerBuilder code to complete the problem if its possible. 如果可能,还提供完整的PowerBuilder代码以完成问题。
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. 在Access中,我们强烈建议完全不使用DSN,因为对于某人而言,这是一件很简单的事情,而对于用户来说,则不那么麻烦了。 Using DSN-Less Connections You should see if PowerBuilder has a similar option.
使用DSN-Less连接您应该查看PowerBuilder是否具有类似的选项。
RegistrySet ( key, valuename, valuetype, value )
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. 设置好DSN后,可以使用许多选项将数据从一个数据库推送到另一个数据库。
You'll need two transaction
objects in PB, each pointing to its own database. 您将在PB中需要两个
transaction
对象,每个transaction
对象都指向其自己的数据库。 Then, you could use a Data Pipeline
object to manage the actual data transfer. 然后,您可以使用
Data Pipeline
对象来管理实际的数据传输。
I am using this code, try it! 我正在使用此代码,请尝试!
//// 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
or 要么
//// 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.