Using ADO to access outside data
ActiveX Data Object (ADO) is a set of COM objects used for accessing data sources. ADO allows developers to write programs to access data without knowing what a database structure is, or how the database is implemented. Let's see how to use ADO in C/AL programing.
How to do it...
Let's get started by creating a new codeunit from Object Designer.
Create a function named
CreateConnectionString
.Add the following parameters to the function:
Name
DataType
Length
ServerName
Text
50
DatabaseName
Text
50
UserName
Text
50
Password
Text
50
Set the function's return value of type
text
with length1024
.Add the following code to the function:
EXIT('Driver={SQL Server};' + 'Server=' + ServerName + ';' +'Database=' + DatabaseName + ';' + 'Uid=' + UserName +';' + 'Pwd=' + Password + ';');
Add the following global variables:
Name
DataType
Subtype
Length
ADOConnection
Automation
'Microsoft ActiveX Data Objects 6.0
Library'.Connection
ADORecordSet
Automation...