[转帖]PB8如何使用OLE DB连接到ASA数据库
<table cellspacing="0" cellpadding="0" width="80%" align="center" border="0"><tbody><tr><td><div><font face="arial, helvetica, geneva"><b><tt>Connecting to ASA Server (7.01 GA) via OLE DB in PowerBuilder 8</tt></b></font></div><div><font face="arial, helvetica, geneva"><tt>Adaptive Server Anywhere includes an <b>OLE DB provider</b> named <b>ASAProv</b>. One of the features of ASAProv (dboledb7.dll) is that you do not have to deploy ODBC. In other words, you can connect to an ASA database either via OLE DB or via OLE DB/ODBC bridge.</tt></font></div><div><font face="arial, helvetica, geneva"><tt>The steps to establish database connection to ASA using OLE DB from PowerBuilder are as follows:</tt></font></div><div><font face="arial, helvetica, geneva"><tt>Start ASADEMO as a server by executing the following line at the command prompt:</tt></font></div><div><font face="arial, helvetica, geneva"><tt> <i>dbsrv7 asademo -x tcpip -n<b> asademo</b></i></tt></font><p><font face="arial, helvetica, geneva"><tt>(<b><i>"asademo"</i></b> - your choice of database server name. Make sure you do not have a similar named server running in your internal network otherwise you will get error running the server)</tt>
<br/> </font></p></div><div><font face="arial, helvetica, geneva"><tt>There are two ways of connecting to an ASA server via OLE DB</tt></font></div><div><font face="arial, helvetica, geneva"><b><tt>1) OLE DB/ODBC bridge</tt></b></font></div><div><font face="arial, helvetica, geneva"><tt>For this connection, you have to specify a valid ODBC DataSource in your DBParm. Your connection script will look like this:</tt></font></div><div><font face="arial, helvetica, geneva"><i><tt> // Profile asa_oledb</tt></i></font></div><div><font face="arial, helvetica, geneva"><i><tt> SQLCA.DBMS = "OLE DB"</tt></i></font></div><div><font face="arial, helvetica, geneva"><i><tt> SQLCA.LogPass = "sql"</tt></i></font></div><div><font face="arial, helvetica, geneva"><i><tt> SQLCA.LogId = "dba"</tt></i></font></div><div><font face="arial, helvetica, geneva"><i><tt> SQLCA.AutoCommit = False</tt></i></font></div><div><font face="arial, helvetica, geneva"><i><tt> SQLCA.DBParm = "PROVIDER='ASAProv',DATASOURCE='asa'"</tt></i>
<br/> </font></div><div><font face="arial, helvetica, geneva"><b><tt>2) OLE DB</tt></b><tt> (do not have to deploy ODBC)</tt></font></div><div><font face="arial, helvetica, geneva"><tt>You can access data from OLE DB by providing connection information in a separate file with a .udl extension. This file is referred to as the Microsoft DataLink (.udl) file. You need to have the Datalink API installed on the system in order to create and use the .udl files.</tt></font></div><div><font face="arial, helvetica, geneva"><tt>To create a data link (.udl) file from Windows Explorer - Right-click within the right pane of an Explorer window or from your desktop and select Microsoft Data Link from the New menu. A new data link .udl file will be created in the current directory.</tt></font></div><div><font face="arial, helvetica, geneva"><tt>If you do not have the option to select Microsoft Data Link in the New menu, then create a .txt file and rename it to a .udl file. DoubleClick on the file, it will open the file with the options to add the connection information.</tt></font></div><div><tt><font face="arial, helvetica, geneva">For more information please check msdn.microsoft.com and search for </font>揇<font face="arial, helvetica, geneva">atalink?/tt></font></tt></div><p><tt><font face="arial, helvetica, geneva">In Powerbuilder, when using the datalink file (.udl), make sure that the Catalog Tables have already been created in the database. To verify, you can connect to the database server using an ODBC DataSource instead. If the tables don</font>抰 <font face="arial, helvetica, geneva">exist, you should get an error indicating that Catalog Tables were not created. </font></tt></p><p><tt><font face="arial, helvetica, geneva">Create an asademo.udl file with following info: </font></tt></p><div><tt><font face="arial, helvetica, geneva"> <b><i>Provider Tab:</i></b></font></tt></div><div><tt><font face="arial, helvetica, geneva"> Select "Adaptive Server Anywhere Provider"</font></tt></div><div><tt><font face="arial, helvetica, geneva"> <b><i>Connection Tab:</i></b></font></tt></div><div><tt><font face="arial, helvetica, geneva"> Location: eng=asademo;dbn=asademo;Links=TCPIP{};</font></tt></div><div><tt><font face="arial, helvetica, geneva"> Select radio button for </font>慤<font face="arial, helvetica, geneva">se a specific username and password?</font></tt></div><div><tt><font face="arial, helvetica, geneva"> Type Username - dba</font></tt></div><div><tt><font face="arial, helvetica, geneva"> Password - sql</font></tt></div><div><tt><font face="arial, helvetica, geneva"> Select checkbox - Allow saving password</font></tt></div><div><tt><font face="arial, helvetica, geneva"> Click "Test Connection" to verify the connection.</font></tt></div><div><tt><font face="arial, helvetica, geneva">If you are using the datalink file in PowerBuilder, you cannot use userid and password from PB script or DB profile. You have to save this information in the udl file itself (cr 239454).</font></tt></div><div><tt><font face="arial, helvetica, geneva">In PB, the connection script will look like this:</font></tt></div><div><tt><font face="arial, helvetica, geneva"> // Profile asa_oledb</font></tt></div><div><tt><font face="arial, helvetica, geneva"> <i>SQLCA.DBMS = "OLE DB"</i></font></tt></div><div><tt><font face="arial, helvetica, geneva"><i> SQLCA.AutoCommit = False</i></font></tt></div><div><tt><font face="arial, helvetica, geneva"><i> SQLCA.DBParm = "PROVIDER='ASAProv',DATALINK='C:\asaole.udl'"</i></font></tt></div><div><tt><font face="arial, helvetica, geneva">You can also refer to TechDoc # 47903 - Connecting to OLE DB Providers from PowerBuilder 7 and 8</font></tt></div><font face="arial, helvetica, geneva"><div><b><tt>Connecting to ASA Server (7.01 GA) via OLE DB in PowerBuilder 8</tt></b></div><div><tt>Adaptive Server Anywhere includes an <b>OLE DB provider</b> named <b>ASAProv</b>. One of the features of ASAProv (dboledb7.dll) is that you do not have to deploy ODBC. In other words, you can connect to an ASA database either via OLE DB or via OLE DB/ODBC bridge.</tt></div><div><tt>The steps to establish database connection to ASA using OLE DB from PowerBuilder are as follows:</tt></div><div><tt>Start ASADEMO as a server by executing the following line at the command prompt:</tt></div><div><tt> <i>dbsrv7 asademo -x tcpip -n<b> asademo</b></i></tt>
<p><tt>(<b><i>"asademo"</i></b> - your choice of database server name. Make sure you do not have a similar named server running in your internal network otherwise you will get error running the server)</tt>
<br/> </p></div><div><tt>There are two ways of connecting to an ASA server via OLE DB</tt></div><div><b><tt>1) OLE DB/ODBC bridge</tt></b></div><div><tt>For this connection, you have to specify a valid ODBC DataSource in your DBParm. Your connection script will look like this:</tt></div><div><i><tt> // Profile asa_oledb</tt></i></div><div><i><tt> SQLCA.DBMS = "OLE DB"</tt></i></div><div><i><tt> SQLCA.LogPass = "sql"</tt></i></div><div><i><tt> SQLCA.LogId = "dba"</tt></i></div><div><i><tt> SQLCA.AutoCommit = False</tt></i></div><div><i><tt> SQLCA.DBParm = "PROVIDER='ASAProv',DATASOURCE='asa'"</tt></i>
<br/><i><tt></tt></i> </div><div><b><tt>2) OLE DB</tt></b><tt> (do not have to deploy ODBC)</tt></div><div><tt>You can access data from OLE DB by providing connection information in a separate file with a .udl extension. This file is referred to as the Microsoft DataLink (.udl) file. You need to have the Datalink API installed on the system in order to create and use the .udl files.</tt></div><div><tt>To create a data link (.udl) file from Windows Explorer - Right-click within the right pane of an Explorer window or from your desktop and select Microsoft Data Link from the New menu. A new data link .udl file will be created in the current directory.</tt></div><div><tt>If you do not have the option to select Microsoft Data Link in the New menu, then create a .txt file and rename it to a .udl file. DoubleClick on the file, it will open the file with the options to add the connection information.</tt></div></font><div><font face="arial, helvetica, geneva"><tt>For more information please check msdn.microsoft.com and search for </tt></font><tt>揇<font face="arial, helvetica, geneva">atalink?/tt></font></tt></div><tt><p><font face="arial, helvetica, geneva"><tt>In Powerbuilder, when using the datalink file (.udl), make sure that the Catalog Tables have already been created in the database. To verify, you can connect to the database server using an ODBC DataSource instead. If the tables don</tt></font><tt>抰 <font face="arial, helvetica, geneva">exist, you should get an error indicating that Catalog Tables were not created.</font></tt>
<font face="arial, helvetica, geneva"><p><tt>Create an asademo.udl file with following info:</tt>
</p><div><tt> <b><i>Provider Tab:</i></b></tt></div><div><tt> Select "Adaptive Server Anywhere Provider"</tt></div><div><tt> <b><i>Connection Tab:</i></b></tt></div><div><tt> Location: eng=asademo;dbn=asademo;Links=TCPIP{};</tt></div></font></p><p><tt>Create an asademo.udl file with following info:</tt>
</p><div><tt> <b><i>Provider Tab:</i></b></tt></div><div><tt> Select "Adaptive Server Anywhere Provider"</tt></div><div><tt> <b><i>Connection Tab:</i></b></tt></div><div><tt> Location: eng=asademo;dbn=asademo;Links=TCPIP{};</tt></div><p></p><p><tt>Create an asademo.udl file with following info:</tt>
</p><div><tt> <b><i>Provider Tab:</i></b></tt></div><div><tt> Select "Adaptive Server Anywhere Provider"</tt></div><div><tt> <b><i>Connection Tab:</i></b></tt></div><div><tt> Location: eng=asademo;dbn=asademo;Links=TCPIP{};</tt></div><div><font face="arial, helvetica, geneva"><tt> Select radio button for </tt></font><tt>慤<font face="arial, helvetica, geneva">se a specific username and password?</font></tt></div><font face="arial, helvetica, geneva"><div><tt> Type Username - dba</tt></div><div><tt> Password - sql</tt></div><div><tt> Select checkbox - Allow saving password</tt></div><div><tt> Click "Test Connection" to verify the connection.</tt></div><div><tt>If you are using the datalink file in PowerBuilder, you cannot use userid and password from PB script or DB profile. You have to save this information in the udl file itself (cr 239454).</tt></div><div><tt>In PB, the connection script will look like this:</tt></div><div><tt> // Profile asa_oledb</tt></div><div><tt> <i>SQLCA.DBMS = "OLE DB"</i></tt></div><div><i><tt> SQLCA.AutoCommit = False</tt></i></div><div><i><tt> SQLCA.DBParm = "PROVIDER='ASAProv',DATALINK='C:\asaole.udl'"</tt></i></div><div><tt>You can also refer to TechDoc # 47903 - Connecting to OLE DB Providers from PowerBuilder 7 and 8</tt></div></font></tt><font face="arial, helvetica, geneva"><p></p></font></td></tr></tbody></table><!--Element not supported - Type: 8 Name: #comment--> <p>我想要中文的。</p> <p>如果用ASA数据库,pb做开发</p><p>还是ODBC方便</p><p>oledb也没什么特别的</p> ........看的头晕, 我也想要中文的
页:
[1]