Hi,
In a DNN custom module I'm making I succesfully filled a DataSet with information from a MS Access Database. I've simply copied ALL the contents of the database into the dataset. I'm wondering, however, how to only copy certain members of the database into the dataset. I've tried using a Select From Where statement to no avail. Here is the code that works (but grabs the whole database). Note the database file is "arpt.mdb" and the only table is named "arpt":
Dim testdb As New OleDb.OleDbConnection
Dim GetTest As New OleDb.OleDbCommand
Dim TestAdapter As New OleDb.OleDbDataAdapter
Dim Testds As New DataSet
testdb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataSourcePath & "arpt.mdb"
GetTest.CommandText = "SELECT * FROM arpt"
GetTest.Connection = testdb
TestAdapter.SelectCommand = GetTest
testdb.Open()
TestAdapter.Fill(Testds, "arpt")
testdb.Close()
What I would like to do, however, is have it select records from the database where field "ICAO" is the same as a variable in my program "dicao". I would think if I changed the code above like this:
GetTest.CommandText = "SELECT * FROM arpt WHERE icao = dicao"
would do the trick but it's not working. I'm sure it's just a formatting error on my part. Can somebody help me with this? Many thanks...