14.01.2015 Views

ChemOffice.Com - CambridgeSoft

ChemOffice.Com - CambridgeSoft

ChemOffice.Com - CambridgeSoft

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

In addition to the file requirements, the<br />

environment must be set up so that the system can<br />

find them. These issues are explained in detail in the<br />

system manuals of the actual platform.<br />

Using ADO<br />

Microsoft's ADO is a convenient way to write client<br />

programs utilizing the cartridge.<br />

To create an Oracle service on any client computer,<br />

the Oracle client tools must be installed, and the<br />

Net8 assistant program must be used to create a<br />

service by entering the following information:<br />

Net Service Name: any valid string would do<br />

(this string must be used in ADO)<br />

Protocol: TCP/IP<br />

Host Name: a computer running the Oracle<br />

server<br />

Port Number: 1521<br />

(Oracle 8i) Service Name: the service name<br />

on the server.<br />

DIM c as ADODB.Connection<br />

set c = new ADODB.Connection<br />

ServiceName = "" Rem the name of Oracle<br />

service<br />

UserName = "" Rem user name<br />

Password = "" Rem password<br />

s =<br />

"Provider=OraOLEDB.Oracle.1;Persist<br />

Security_ Info=False;Data Source=" +<br />

ServiceName + ";"<br />

s = s + "User ID=" + UserName + ";"<br />

s = s + "Password=" + Password<br />

c.Open s<br />

Dim r as ADODB.Recordset<br />

Set r = c.Execute("SELECT * FROM<br />

moltable WHERE_<br />

CsCartridge.MoleculeContains(mol,<br />

'c1ccccc1','', '')=1");<br />

Rem process the recordset<br />

c.Close<br />

NOTE: When using Microsoft ADO data controls to<br />

access the cartridge, the CursorLocation property must be set<br />

to adUseServer. Otherwise data updates will fail, if the<br />

structure field is larger, then 4000 bytes.<br />

Example of passing large<br />

queries<br />

NOTE: <strong>Com</strong>ments are in bold.<br />

Dim r As ADODB.Recordset<br />

ChemDrawCtl1.DataEncoded = True '<br />

b64 encoded cdx is required<br />

Dim s As String<br />

s = ChemDrawCtl1.Data("cdx") '<br />

get the cdx document from the ChemDraw<br />

ActiveX control<br />

Dim com As ADODB.<strong>Com</strong>mand '<br />

create a new ADODB.command<br />

Set com = New ADODB.<strong>Com</strong>mand<br />

Rem now build the sql string step by<br />

step, and create the corresponding<br />

parameters as well<br />

Rem the query data will be passed as an<br />

array defined in CsCartridge<br />

Rem<br />

sql = "Select " + idSelect '<br />

idSelect contains the column name to be<br />

selected<br />

sql = sql + " from " + TableName ' from<br />

table<br />

sql = sql + " where<br />

CsCartridge.MoleculeContains(" +<br />

StructName '<br />

first param is column name of the<br />

chemical structure<br />

sql = sql + ", CsCartridge.Xarray(" '<br />

second param is an array of string<br />

<strong>ChemOffice</strong> Enterprise Workgroup & Databases 2005 CS Oracle Cartridge • 201<br />

Using ADO

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!