ehxz 发表于 2007-6-26 12:51:34

[转帖]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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <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/>&nbsp;</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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Profile asa_oledb</tt></i></font></div><div><font face="arial, helvetica, geneva"><i><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.DBMS = "OLE DB"</tt></i></font></div><div><font face="arial, helvetica, geneva"><i><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.LogPass = "sql"</tt></i></font></div><div><font face="arial, helvetica, geneva"><i><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.LogId = "dba"</tt></i></font></div><div><font face="arial, helvetica, geneva"><i><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.AutoCommit = False</tt></i></font></div><div><font face="arial, helvetica, geneva"><i><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.DBParm = "PROVIDER='ASAProv',DATASOURCE='asa'"</tt></i>
                                                        <br/>&nbsp;</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&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><i>Provider Tab:</i></b></font></tt></div><div><tt><font face="arial, helvetica, geneva">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select "Adaptive Server Anywhere Provider"</font></tt></div><div><tt><font face="arial, helvetica, geneva">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><i>Connection Tab:</i></b></font></tt></div><div><tt><font face="arial, helvetica, geneva">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Location: eng=asademo;dbn=asademo;Links=TCPIP{};</font></tt></div><div><tt><font face="arial, helvetica, geneva">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Type Username - dba</font></tt></div><div><tt><font face="arial, helvetica, geneva">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Password - sql</font></tt></div><div><tt><font face="arial, helvetica, geneva">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select checkbox - Allow saving password</font></tt></div><div><tt><font face="arial, helvetica, geneva">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Profile asa_oledb</font></tt></div><div><tt><font face="arial, helvetica, geneva">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <i>SQLCA.DBMS = "OLE DB"</i></font></tt></div><div><tt><font face="arial, helvetica, geneva"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.AutoCommit = False</i></font></tt></div><div><tt><font face="arial, helvetica, geneva"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <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/>&nbsp;</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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Profile asa_oledb</tt></i></div><div><i><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.DBMS = "OLE DB"</tt></i></div><div><i><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.LogPass = "sql"</tt></i></div><div><i><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.LogId = "dba"</tt></i></div><div><i><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.AutoCommit = False</tt></i></div><div><i><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.DBParm = "PROVIDER='ASAProv',DATASOURCE='asa'"</tt></i>
                                                        <br/><i><tt></tt></i>&nbsp;</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&gt;</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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><i>Provider Tab:</i></b></tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select "Adaptive Server Anywhere Provider"</tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><i>Connection Tab:</i></b></tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><i>Provider Tab:</i></b></tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select "Adaptive Server Anywhere Provider"</tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><i>Connection Tab:</i></b></tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><i>Provider Tab:</i></b></tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select "Adaptive Server Anywhere Provider"</tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><i>Connection Tab:</i></b></tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Location: eng=asademo;dbn=asademo;Links=TCPIP{};</tt></div><div><font face="arial, helvetica, geneva"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Type Username - dba</tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Password - sql</tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select checkbox - Allow saving password</tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Profile asa_oledb</tt></div><div><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <i>SQLCA.DBMS = "OLE DB"</i></tt></div><div><i><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLCA.AutoCommit = False</tt></i></div><div><i><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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-->

yesfang 发表于 2007-9-4 16:27:34

<p>我想要中文的。</p>

ljq900 发表于 2007-10-18 14:48:32

<p>如果用ASA数据库,pb做开发</p><p>还是ODBC方便</p><p>oledb也没什么特别的</p>

lovelyni 发表于 2007-12-19 22:06:13

........看的头晕,

lovelyni 发表于 2007-12-19 22:13:22

我也想要中文的
页: [1]
查看完整版本: [转帖]PB8如何使用OLE DB连接到ASA数据库

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com