Here is a code snippet that I use quite frequently when I need info from my database in table form:
Dim oPartsConn As New OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString-Parts"))
Dim daParts As OleDbDataAdapter
Dim dtParts As New DataTable
oPartsConn.Open()
sSQL = "SELECT * FROM Parts"
dtParts.Clear()
If Not Me.daParts Is Nothing Then Me.daParts.Dispose()
daParts = New OleDbDataAdapter(sSQL, oPartsConn)
daParts.MissingSchemaAction = MissingSchemaAction.AddWithKey
daParts.AcceptChangesDuringFill = False
daParts.Fill(dtParts)
Of course, the sSQL can have any SELECT statement in it, and I encountered a problem when I was using this snippet with a particularly complicated SELECT. I kept getting a "Timeout Expired." error in the Catch portion of the Try-Catch surrounding this snippet.
Here's the solution: Add this line before the .Fill line:
daParts.SelectCommand.CommandTimeout = 300

