Avatar of DGWParker

asked on 

Populate VB DataGrid from Recordset

Populate VB DataGrid from Recordset

Could someone please help me and complete the following sub procedure.
(I am not sure if I should ask this Q on in the VB area?)

I have a Datagrid placed on a Visual Basic Form.
When I open the form, I want the Datagrid to be populated with data from a select
(Could you also please let me know which library references to use.)

Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset

Private Sub Form_Load()

Set cnn = New ADODB.Connection
cnn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;
Persist Security Info=False;Initial Catalog=Northwind;Data Source=SQLServer"
Set rst = New ADODB.Recordset
Set DataGrid1.DataSource = rst

End Sub
Microsoft SQL Server

Avatar of undefined
Last Comment
Anthony Perkins

8/22/2022 - Mon