what are the steps of connectivity with database in vb?

1: Create table in the Oracle

2: Set up connectivity using data source

a) Open the control panel -> Administrative tools -> Data sources

b) System DSN -> Add -> MS ODBC for oracle -> Ok

c) DSN = ‘Table Name’ [Created in Oracle]

d) Username = scott -> ok “scott is login name for oracle”

3: Set up VB

a) Right click adodc control -> properties.

b) Use connection string ->build.

c) Select driver MS OLE DB provider for ODBC drivers -> next.

d) Select DSN table name voter from list.

e) Type username and password “scott and tiger” which ever used for logging in oracle.

f) Allowing saving password -> test connection. -> if test connection successful then proceed,
else check again the above steps.

g) Copy the string generated in use connection string.

h) Paste it in the connection to open E.g. conv.Open “Provider=MSDASQL.1;Password=tiger;Persist Security Info=True;User ID=scott;Data Source=voter;Initial Catalog=Employees”

Now the code will look like this:-

Private Sub Form_Load()

Dim oconn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
strSQL = “SELECT * FROM employees”
Set oconn = New ADODB.Connection
oconn.Open “Provider=MSDASQL.1;Password=tiger;Persist Security Info=True;User ID=scott;Data Source=employees”
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.LockType = adLockOptimistic
rs.Open strSQL, oconn, , , adCmdText
Set DataGrid1.DataSource = rs
End Sub

PART – 2

1: To add a reference, select Project-References from the Visual Basic Menu Bar, then select Microsoft ActiveX Data Objects 2.6 Library.

2: Select Project-Components from the Visual Basic Menu Bar, and select Microsoft DataGrid Control 6.0.

3: Add Data Grid Control to your VB Form

Leave a Reply

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