I connect to SQL Server database and grab a DataSet of the result with the following function:
Public Function GetDataSQL(ByVal queryString As String, ByVal addParameters As Action(Of SqlParameterCollection)) As DataTable
Dim result As New DataTable()
Using cn As New SqlConnection("server=.\sqlexpress;Integrated Security=SSPI; database=Pancakes"), _
cmd As New SqlCommand(queryString, cn)
addParameters(cmd.Parameters)
cn.Open()
Using rdr = cmd.ExecuteReader()
result.Load(rdr)
End Using
End Using
Return result
End Function
Then I do a virtually identical function to get the result of a query to an Access database.
How can I do an “INNER JOIN” on these two datasets? There is a “merge” method, but I don’t think it does an “INNER JOIN”…
Since you’re bringing your results back as DataTables, you will need to use something like LINQ to DataSets or set up associations between your DataTables in the DataSet. If you want to read up on LINQ to DataSets, checkout the free bonus chapter 14 at http://www.manning.com/marguerie/.