Seems to be a nice start dilip! lemme make u clear how to conncet sql as a backend to vb!
->To conncet VB with sql, we need ADO
For this ,I am using a simple form. I have a button dragged and dropped on the form. Here I plan to simply use a Connection object and a Recordset object to retrieve records. These two objects shall do to serve our purpose for the moment. I am not using any control to display data; I intend to display data on the form itself. This post will show you how to fetch records, find the total number of records fetched and how to access the values of each field.
->We have to create instances of a Connection and a Recordset object in our button’s click object.
nw consider this code!
Dim MyConnObj As New ADODB.Connection
Dim myRecSet As New ADODB.Recordset->To create a Connection to a database we use the Connection object’s Open method
MyConnObj.Open _
"Provider = sqloledb;" & _
"Data Source={ServerName};" & _
"Initial Catalog={DatabaseName};" & _
"User ID={UserName};" & _
"Password={Password};"this is normally we used to call as connection string!
Next we use the Recordset object’s Open mentod to fetch records from a table (myTable):
myRecSet.Open “select * from myTable”, MyConnObj, adOpenKeyset->Let us suppose that my table has three fields. You can refer to a data in the first field using the RecordSet object as:
Msgbox myRecSet(0)The index 0 maps to the first field, 1 maps to data in the second field, and so on…However this analogy will not allow you to get the next record! So how do we get the information pertaining to the next record? itz simple

use the below code!
myRecordSet.MoveNext->So now the question comes: you know how to open a connection, you know how to fetch records, and you know how to point to the next record. But how will you know when the records fetched exhausts? How will you know if the last record has reached?
*There are two ways. To know the numbers of records before hand we can use the RecordCount property of the Recordset object.
Msgbox “Total no of records = ”& myRecSet.RecordCount->Another way is to iterate; we can move the pointer to the next record and check if the EOF property is True or not. This is what I have used to print data on the form.
This is my example module:
Private Sub Command1_Click()
Dim MyConnObj As New ADODB.Connection 'ADODB Connection Object
Dim myRecSet As New ADODB.Recordset 'Recordset Object
Dim sqlStr As String ' String variable to store sql command
MyConnObj.Open _
"Provider = sqloledb;" & _
"Data Source=172.16.1.60;" & _
"Initial Catalog=TESTATV;" & _
"User ID=sa;" & _
"Password=p@ssW0rd;"
sqlStr = "select * from employee"
myRecSet.Open sqlStr, MyConnObj, adOpenKeyset
MsgBox "Total Number of records = " & myRecSet.RecordCount
Dim i As Integer 'variable to keep count
i = 1
Print "#"; Tab; "ID"; Tab; "Name"; Tab; "Salary"
Print ""
While Not myRecSet.EOF ' Loop until endd fo file is reached
Print i; Tab; myRecSet(0); Tab; myRecSet(1); Tab; myRecSet(2)
'0- 1st filed, 1- 2nd Field and so on...
myRecSet.MoveNext 'Moves the RecordSet pointer to the next position
i = i + 1
Wend
MyConnObj.Close
End Sub->If u follow these steps and constraints carefully, then my friend, there will be no problem in establishing connection!