ssCore.ADO.setConnectString

Provide an ADO connection string that identifies the data provider and the data source you want to use.


Availability:

First available in version 3.0 build 2039.


Input Parameters:

connectString - An ADO connection string.


Output Parameters:

No output parameters.


Asynchronous Mode:

When this method is called asynchronously, a return object containing the output parameters is passed to the specified callback function.

ssCore.ADO.setConnectString( paramsObject [, callbackParamsObject] [, errorParamsObject] );


Synchronous Mode:

When this method is called synchronously, a return object containing the output parameters is returned to the caller immediately.

var returnObject = ssCore.ADO.setConnectString( paramsObject );


Notes:

You must call ADO.setConnectString before ADO.open or the open operation will fail.

Any file format with an OLEDB driver can be accessed using ADO. The trick is in getting the right connection string for the OLEDB drivers you have. Carl Prothman has put together a great resource page full of ADO connection strings for a lot of different OLEDB providers includng Microsoft Jet (Access), FoxPro, Oracle, SQL Server, MySQL, Excel, Exchange and even text files!

Connection strings can be big and messy so Microsoft provided another way for you to tell ADO how to connect to your OLEDB provider. Instead of a complicated connection string you can just provide a reference to a Universal Data Link (UDL) file in your connection string like ssCore.ADO.setConnectString({connectString: "File Name=C:\\MyFile.UDL;"}). The UDL file actually contains a connection string, but Microsoft has created a nice wizard you can use to create and configure UDL files.

Be sure to read Connection String Syntax to make sure your connection strings are properly defined. One important thing to note is that any leading or trailing spaces around a keyword or value are ignored. However, spaces within a keyword or value are allowed, recognized and significant.

                

Examples:

The following example sets the connection string to connect to an MS Access database that is located in the same folder as our application.

ssCore.ADO.setConnectString({connectString:"Provider=Microsoft.Jet.OLEDB.4.0; Persist Security Info=False; Data Source="+ssGlobals.ssStartDir+"\\database.mdb;"});