Upload
riya-jain
View
215
Download
0
Embed Size (px)
Citation preview
8/8/2019 Database Connectivity Using RDO
1/6
Database connectivity using RDO (Remote data Object)
RDO uses ODBC (Open Data Base Connectivity), an ODBC Data Source, which must be set up through
the Windows Control Panel. Follow the steps below to set up an ODBC Data Source (this process is also
called "setting up a DSN", where "DSN" stands for "Data Source Name").The following steps is used to
setup system DSN as:
1.) Go to Start -> Windows Control Panel; double-click on Administrative Tools, then Data
Sources (ODBC). The ODBC Data Source Administratorscreen is displayed. Click on the
System DSN tab.
8/8/2019 Database Connectivity Using RDO
2/6
2.) Click the Add button. The Create New Data Source dialog box will appear. Select Microsoft
Access Driver (*.mdb) from the list and click the Finish button.
3.) The ODBC Microsoft Access Setup dialog box will appear. ForData Source Name, type
Biblio. If desired, you can type an entry forDescription, but this is not required.
4.) Click the Select button. The Select Database dialog box appears. On a default installation of
VB6 or Visual Studio 6, the BIBLIO.MDB sample database should reside in the folder
C:\Program Files\Microsoft Visual Studio\VB98. Navigate to that folder, select BIBLIO.MDB
from the file list, and click OK.
8/8/2019 Database Connectivity Using RDO
3/6
5.) When you are returned to the ODBC Microsoft Access Setup screen, the database you selected
should be reflected as shown below. Click OK to close this screen.
8/8/2019 Database Connectivity Using RDO
4/6
6.) When you are returned to the ODBC Data Source Administrator screen, the new DSN should
appear as shown below. Click OK to close this screen.
Connecting VB application to MS Access database using the
RDO Data Control (RDODC):
1.) Start a new VB project, and from the Components dialog box (invoked from the Project ->
Components menu), select Microsoft Remote Data Control 6.0 (SP3) as shown below and
click OK.
2.) Drag & Drop a remote data control (RDC) on your form, and set the properties as follows:
Property Value
Name MSRDC1
DataSourceName Select the DSN name as created above. Eg. Biblio
SQL select * from Customers
8/8/2019 Database Connectivity Using RDO
5/6
3.) Now put three text boxes on the form, and set their Name, DataSource, and DataField properties
as follows:
Name DataSource DataField
Textbox1 MSRDC1 CustomerName
Textbox2 MSRDC1 CustomerID
Textbox3 MSRDC1 Phone
4.) Save and run the program. It works just like the other data control.
Code for Add, delete, edit, update, movefirst, movenext, first, last
operations on the click event of command button:
Private Sub Command1_Click()
MSRDC1.Resultset.AddNew
End Sub
======================
Private Sub Command2_Click()
MSRDC1.Resultset.Delete
End Sub
Private Sub Command3_Click()
MSRDC1.Resultset.MoveFirst
End Sub
8/8/2019 Database Connectivity Using RDO
6/6
Private Sub Command4_Click()
MSRDC1.Resultset.Update
End Sub
Private Sub Command5_Click()
MSRDC1.Resultset.Edit
End Sub
Private Sub Command6_Click()
MSRDC1.Resultset.MovePrevious
End Sub
Private Sub Command7_Click()
MSRDC1.Resultset.MoveFirst
End Sub
Private Sub Command8_Click()
MSRDC1.Resultset.MoveLast
End Sub