First off I'm not even sure if this is the right area to post so please advise if not correct. Second I just started trying to convert my Access DB to Visual Basic (Visual Studio). I created a form and a ListView. I can get the headers on the form with no problems. I created an ADO connection to my Access DB but am not sure of the syntax on how to loop through my recordset and put info into my ListView. Below is the code I have so far (Be gentle with me). If someone could nudge me in the right direction it would be great!!
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, ListView1.Resize, MyBase.Resize
'TODO: This line of code loads data into the 'Audit_DatabaseDataSet.tblhistory' table. You can move, or remove it, as needed.
Dim cnt As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim strDSN As String
strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\Lwcfil01\public\Safety\Audit Database\Audit_Database.mdb;"
strSQL = "SELECT * FROM QRYhistory;"
cnt.Open(strDSN)
rst = cnt.Execute(strSQL)
ListView1.View = View.Details
With ListView1.Columns
.Add("Mycounter", 0, HorizontalAlignment.Left)
.Add("Audit Number", 100, HorizontalAlignment.Left)
.Add("Status", 100, HorizontalAlignment.Left)
.Add("Assigned To", 150, HorizontalAlignment.Left)
.Add("Date Audited", 150, HorizontalAlignment.Left)
.Add("Area Audited", 150, HorizontalAlignment.Left)
.Add("Product Team", 100, HorizontalAlignment.Left)
.Add("Auditor", 150, HorizontalAlignment.Left)
.Add("Shift Audited", 100, HorizontalAlignment.Left)
.Add("Issue", 150, HorizontalAlignment.Left)
.Add("Comments", 200, HorizontalAlignment.Left)
.Add("Positive Comment", 150, HorizontalAlignment.Left)
.Add("Positive Comments", 150, HorizontalAlignment.Left)
.Add("Action Items", 200, HorizontalAlignment.Left)
.Add("To Be Completed", 150, HorizontalAlignment.Left)
.Add("Date Completed", 150, HorizontalAlignment.Left)
End With
'How do I fill the ListView using my ADO recordset?
'Close recordset
rst.Close()
cnt.Close()
rst = Nothing
cnt = Nothing
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, ListView1.Resize, MyBase.Resize
'TODO: This line of code loads data into the 'Audit_DatabaseDataSet.tblhistory' table. You can move, or remove it, as needed.
Dim cnt As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim strDSN As String
strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\Lwcfil01\public\Safety\Audit Database\Audit_Database.mdb;"
strSQL = "SELECT * FROM QRYhistory;"
cnt.Open(strDSN)
rst = cnt.Execute(strSQL)
ListView1.View = View.Details
With ListView1.Columns
.Add("Mycounter", 0, HorizontalAlignment.Left)
.Add("Audit Number", 100, HorizontalAlignment.Left)
.Add("Status", 100, HorizontalAlignment.Left)
.Add("Assigned To", 150, HorizontalAlignment.Left)
.Add("Date Audited", 150, HorizontalAlignment.Left)
.Add("Area Audited", 150, HorizontalAlignment.Left)
.Add("Product Team", 100, HorizontalAlignment.Left)
.Add("Auditor", 150, HorizontalAlignment.Left)
.Add("Shift Audited", 100, HorizontalAlignment.Left)
.Add("Issue", 150, HorizontalAlignment.Left)
.Add("Comments", 200, HorizontalAlignment.Left)
.Add("Positive Comment", 150, HorizontalAlignment.Left)
.Add("Positive Comments", 150, HorizontalAlignment.Left)
.Add("Action Items", 200, HorizontalAlignment.Left)
.Add("To Be Completed", 150, HorizontalAlignment.Left)
.Add("Date Completed", 150, HorizontalAlignment.Left)
End With
'How do I fill the ListView using my ADO recordset?
'Close recordset
rst.Close()
cnt.Close()
rst = Nothing
cnt = Nothing
End Sub
End Class