I am trying to translate something i did in Access and ADO to VB.NET and ADO.NET. Any help would be greatly appreciated.
Here's my old code:
Dim strCnn As String
Dim strSQL1 As String
Dim strSQL2 As String
Dim cnn As New ADODB.Connection
Dim rst1 As New ADODB.Recordset
Dim rst2 As New ADODB.Recordset
' my connection string
strSQL1 = "SELECT HLC, M FROM TableName1"
rst1.Open strSQL1, cnn
' retrieve field names and aliases for second recordset
Do Until rst1.EOF
strSQL2 = strSQL2 & rst1!M & " " & rst1!HLC & ", "
strSQL2 = "SELECT " & Left(strSQL2, Len(strSQL2) - 2) & " FROM TableName2"
rst2.Open strSQL2, cnn
Do Until rst2.EOF
' do something
Set rst1 = Nothing
Set rst2 = Nothing
Set cnn = Nothing
I am very new to VB.NET and ADO.NET, so I don't mind very detailed and comprehensive answers.