Tuesday 5 July 2016

How to Connect Datagrid control with Access database without using adodc

Visual Basic 6 :How to connect  DataGrid control with Access database without using ADODC (ADO data control) and display data in the datagrid control-Visual Basic 6.0 Tutorial -Step by Step



Code:
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub Form_Load()
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Database Folder\Student Database.mdb;Persist Security Info=False"
rs.CursorLocation = adUseClient
rs.Open "Select * from Student_Info", con, adOpenKeyset, adLockPessimistic, adcmdtxt
Set DataGrid1.DataSource = rs
DataGrid1.Refresh
Set rs = Nothing
End Sub

If you like my work ,Please hit LIKE button and Subscribe to my channel

3 comments:

  1. teacher! if i want to load data from 2 tbls into datagrid. how should we do and what is the code?

    ReplyDelete
  2. teacher! if i want to load data from 2 tbls into listview. how should we do and what is the code?

    ReplyDelete
  3. How to add details in datagrid control???(VB 6.0)

    ReplyDelete