KB-33921: Connection with an INFOMIX database via scripts.

Question:

How can I connect to an INFOMIX database via scripts?

Solution:

To connect to an INFOMIX database via scripts, you can use the following methods:

Set DBConnection = CreateObject(“ADODB.Connection”)
DBConnection.Open DBConnStr

Where:

DBConnStr = Provider=Ifxoledbc;Data Source=dbName@serverName;User ID=myUsername;Password=myPassword;

To run a query, use:

DBConnection.Execute _
“UPDATE Table SET name = ‘Alex’ WHERE id = 10”

To view all the desired records, returned in Recordset (query) format, you can use the following script:

Set Recordset = CreateObject(“ADODB.Recordset”)
Recordset.Source = “Table”
Recordset.ActiveConnection = DbConnection
Recordset.CursorType = 1 ‘ adOpenKeyset
Recordset.LockType = 3 ‘ adLockOptimistic
Recordset.Open

From that moment on, you will be able to browse the table via MoveNext and MovePrev commands, as well as via a series of other commands supplied by ADO. You will also be able to use an SQL query to handle specific parts of the table via Source property.

This type of access must only be used in cases where no other solution is possible.

The connection in the example uses ActiveX ADO.

NOTE: For further details on connection strings, check The Connection Strings Reference.

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *