Tuesday, 14 February 2017

How to create a connection with the help of RDO reference?

Firstly Create DSN(Data Source Name) using following steps:
1.      open control panel->Select Administrative tool->select DataSources(ODBC) and double click on it, open a dialog box whose name is ODBC Data Source Administrator and select user DSN tab
2.      click on Add button->Create New Data Source window is open->select a driver for which you want to set up a data source->click on finish button
3.        Again open a dialog box where you give data source name and description->click on select button ->ok.
After the above steps we again follow the following steps…

1. Open Standard.EXE from New Project window->go to project menu->References-> Select Microsoft Remote Data Object 2.0->OK

2. Write the following code on the General Section
Dim dbAsrdoConnection
Dim rsAsrdoResultset

3. Write the following code in Form_Load() Section

   Private Sub Form_Load()

Set db = rdoEngine.rdoCreateEnvironment(0).OpenConnection("MyDSN")
sSQL = "select * from Table Name"
Set rs = db.OpenResultset(sSQL, rdOpenKeyset)
rs.Close
db.Close

   End Sub

No comments:
Write comments