You are on page 1of 21

31/1/2021 How to connect to an SQL database server

Show
Home > Connecting to an SQL database server > How to connect to an SQL database server
How to connect to a SQL database server
Topic group Related topics

There are two ways to connect to an SQL database server.


1 - using BDE Aliases and connecting using ODBC drivers (through an ODBC DSN)
2 - using ADO Aliases and connecting using ADO OLE DB or ODBC drivers (through an ODBC DSN)

1 - Using BDE ALIASES


If you are connecting your dBASE Plus application to an SQL database, you need to configure your SQL Links Driver and BDE to access your SQL
database. In this procedure, you create an alias that BDE uses to locate the SQL database. You then add this alias to the Database object on your
dBASE Plus form or report.
Install and configure the server software
Consult the documentation for your SQL database management system product for specific guidance on the initial steps of the following general
procedure (specific product requirements may differ).
1. Make sure you have properly installed the client software for the database management system product to which you want to connect (Oracle, Sybase, InterBase, IBM DB2,
MS SQL Server or Informix).
2. Define server names or other connection strings in the product’s required configuration files. For example, in Oracle, TNSNAMES.ORA, or in Sybase, SQL.INI, and so on.
3. Test the connection by using the database vendor’s connection utility (such as Sybase’s SYBPING.EXE). If you cannot "ping" the server with this utility, BDE and dBASE
Plus will probably not be able to access it either.
4. Make sure that both BDE and the SQL Links drivers are properly installed. The SQL Links drivers are included with the dConnections connectivity component for dBASE
Plus. If properly installed, the SQL Links drivers for Oracle, Sybase, InterBase, IBM DB2, Ms SQL Server and Informix appear on the Configuration page of the BDE
Administrator, which is available from the dBASE Plus program group off the Start menu.

Configure the Borland Database Engine (BDE)


The Borland Database Engine (formerly called IDAPI) allows dBASE Plus to share data with supported SQL databases, Access 95/97, and FoxPro. If
you’ll be connecting to any of these databases, you must assign aliases to them and otherwise configure BDE with the parameters of the database.
To create an alias and configure the BDE,
5. Open the BDE Administrator (BDEADMIN.EXE), available from your dBASE Plus program group.
6. Click the Databases tab.
7. Right-click and choose New to create a new alias.
8. Enter the full path to the database, including the file name when appropriate.
9. Click the Configuration tab and set the appropriate parameters in the Definition panel.

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 1/21
31/1/2021 How to connect to an SQL database server
Parameters may vary according to vendor.
Parameters in bold cannot be changed.
To accommodate record locking in a Windows NT server environment, it is necessary to set the BDE's localShare parameter to "true".
Note
If you're creating a new ODBC alias, you must define its DSN before you can connect to that database.
You’ll find complete instructions in the BDE Administrator Help system. Press F1 with the cursor in any parameter for information on that parameter.

2 - Using ADO Connection Aliases

Setting up an ODBC / ADO Driver

Steps needed to load an ODBC driver to use with ADO support in dBASE PLUS 9. This paper assumes the user will be using Windows 7 or 8 – 64 bit operating
systems and is detailing how to set the environment with MySQL drivers.

Microsoft Windows Database Connectivity support


This subject is focused on setting up an ADO driver for connection to a MySQL database. If you are not familiar with ADO from Microsoft, the
following is from Microsoft:
“Microsoft ActiveX Data Objects (ADO) enable your client applications to access and manipulate data from a variety of sources through an
OLE DB provider. Its primary benefits are ease of use, high speed, low memory overhead, and a small disk footprint. ADO supports key
features for building client/server and Web-based applications.” Microsoft – MSDN
ADO, much like the BDE, also supports the other database connectivity solution called ODBC (Open Database Connectivity) and it will allow
connection to be passed from ODBC through ADO, again much like the BDE. This example will be using an ODBC driver to communicate through
ADO, as MySQL does not support an OLE DB driver.

Installing the 64-bit MySQL Driver (Windows 64-bit OS)

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 2/21
31/1/2021 How to connect to an SQL database server

Download the driver from Oracle for the MySQL driver 64-bit. This can be easily found by typing in Google: ADO MYSQL Driver and it will take
you to the driver locations for download.

Once the driver has been downloaded (in this case an .MSI) run it and follow the installation steps next.

Installing the 64-bit Driver Process:


This is the normal install process that occurs in Windows software.

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 3/21
31/1/2021 How to connect to an SQL database server

Installing Windows 7 – 64 bit using a 32-bit driver


Install the software, again this installation is no different than any other Windows install.

Why do you need to load both 32-bit and 64-bit drivers?


There are issues with the drivers, so having both 32-bit and 64-bit on the machine clears up the issues. This may be fixed in a future version of the
drivers, but as of today, both drivers need to be loaded. Additional information can be found here: http://msdn.microsoft.com/en-
us/library/ms712362(VS.85).aspx

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 4/21
31/1/2021 How to connect to an SQL database server

Setting up the ODBC Driver before dBASE PLUS 9


Since MySQL only supports ODBC and not OLE DB, we have to configure an ODBC data source in the Windows OS for the connectivity.
If you are in Windows XP, Vista, or Win 7, click the Start button
and then Type in ODBC in the Search or Run edit boxes. This
should lead to Data Sources (ODBC) being displayed in the search
results, click on that item to continue.

If you are using Windows 8, hold down the Windows keyboard


button and hit or press the letter E. This will bring you up to the
same search box in Windows 8. Type in ODBC and the search
should return Data Sources (ODBC) and click on that item to
continue.

Click the ADD button to add a new ODBC data Select the MySQL ODBC driver and click the
source Finish button

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 5/21
31/1/2021 How to connect to an SQL database server

Put in the Data Source Name to Fill in the IP and Port address for
be used for the connection the MySQL database. Then input
the User name, Password, and
Database to connect.

There are Advanced options


under the Details>>
button. Set these if you need
to.

Click the Test button to ensure


connection success. Click the When returning from the configure
OK button and then click the dialog, you should see your new
main Window’s OK button to Data Source in the list
exit that dialog. above. Press OK to continue

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 6/21
31/1/2021 How to connect to an SQL database server

Setting up UDL Source:


A universal data link (.udl) file is essentially a text file that contains the connection string for an OLE DB data source. [Microsoft/msdn] Creating a
UDL connection is very easy in Windows, and the following is the step-by-step instructions for doing the process.
Rename the .txt file to a
name like
MySQL_ADO.UDL – it is
extremely important to
make sure the extension is
.UDL! The name can be
anything, but the
extension has to be .UDL.

For this example, create a new Text file on the


Desktop in Windows.

The icon should change


from a text file to a new
icon shown in the picture.

Once you leave the rename, a warning will be


displayed stating changing the extension could
have drastic affects. We want it to, so press the
Yes button to continue

Right-mouse click
on the .UDL file
and select the
Properties menu
item.

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 7/21
31/1/2021 How to connect to an SQL database server

This opens up the configuation setting for the Now select the ODBC provider and click the next
UDL file. Click on the Provider Tab to continue. button. Note: This could take you to security,
however, you want to click on the Connection tab
if the security panel looks correct.

Test the
https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 8/21
31/1/2021 How to connect to an SQL database server

connection. You
should see
Succeeded and then
press the OK
button. Next press
the OK button on the
Properties dialog to
continue.

Use the Data Source name that we created with


the ODBC process in the prior steps. Click the
down-arrow and select if from the list.
Now adding to dBASE PLUS 9

Open dBASE PLUS 9 and click on the Menu Properties|Deskotp Properties menu item

Using the UDL method:

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 9/21
31/1/2021 How to connect to an SQL database server

Now use the UDL file that was setup in the prior steps.

Click the Connection UDL File radio button and


Click on the Connection Aliases tab. Add an click the File name.
Alias name and click the pencil icon.

Chose the UDL file listed on the Desktop Click the Add button and then click the Apply
button

Setting up the Connection by creating a Connection String:


This can be done using a string of characters to connect to a database.

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 10/21
31/1/2021 How to connect to an SQL database server

Type in the name of the Alias then click the This time click on the Connection statement radio
Pencil icon. button. Then click the Data Link Properties
button.

NOTE: If you are planning to build a connection


string, you must start dBASE as administrator so
that the proper rights to create database
connections is enabled.

The following dialog will be displayed. Click the


New… button

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 11/21
31/1/2021 How to connect to an SQL database server

Now click on the Use Connection String radio


button and then hit the Build button.

Name your data source, then press the Next >


button.

This is a review pane. If everything looks correct


press the Finish button

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 12/21
31/1/2021 How to connect to an SQL database server

This can be a very long list. Find the Driver you


are looking for and select it. In this example we
will use the MySQL ODBC driver, then press
the Next > button to continue

This is displayed after clicking on the last Ok


button. The dialog should look as it did when we
first started adding the Data Source.

The “manfacturer” database connection dialog


will be displayed.

NOTE: The Data Source Name and Description


is not enabled; that information was collected
earlier in the process.

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 13/21
31/1/2021 How to connect to an SQL database server

Now, put in the TCP/IP address of the database,


the Port, User Name, Password and click the
Database dropdown to see the databases. If it
shows databases you are connected. After
picking the database click the Test button to
ensure it.

Now use the slider to find the datasource that was


defined in the prior steps.

Select it and then press the OK button. The connection dialog is displayed to check your
security credentials.
NOTE: The reason for this is because the person
could leave the process at any time and return at a

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 14/21
31/1/2021 How to connect to an SQL database server

later time. The connection credential needs to be


checked.
After inserting the security credentials, click the
OK button to continue

Press the Test Connection Button. You should see


the above dialog.

Press the Ok on the Data Link Properties diaog.

Notice the Connection String edit box is now


filled with the full connection string.

Notice now that the full connection string is


located in the Connection statement area. Press
the OK button to continue.

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 15/21
31/1/2021 How to connect to an SQL database server

Now that the String is filled in, press the Add


button and then press the Apply button, press the
OK button to finish out the process.

Using the Connection in dBASE PLUS 9:


Now it is time to connect the defined databases with the included ADO components.

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 16/21
31/1/2021 How to connect to an SQL database server

Create a new form, but do not use the Wizard. Now go to the ADO Access tab on the Component palette.

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 17/21
31/1/2021 How to connect to an SQL database server

Drop an ADODataBase and an ADOTable component onto the form.

ADODatabase Properties ADOTable Properties

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 18/21
31/1/2021 How to connect to an SQL database server

Set the Database Name property to the property Set the Database Name to the Connection on the
we defined in the UDL or Database Connection ADOTable and input the Table Name property
String process that was completed earlier. Then and then set the Active property to True.
set the Active property to True.
https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 19/21
31/1/2021 How to connect to an SQL database server

In the Fields tool window, drag a Column to the form.

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 20/21
31/1/2021 How to connect to an SQL database server

You should see the Column on your form showing data.

https://www.dbase.com/help/9_4/Installing/IDH_INSTALL_SQLCONNECT.htm 21/21

You might also like