Forgive me if this is obvious, but I'm still getting used to ADO.NET and it is a Monday morning.
I'm making a simple form to display data from an Access database. The relevant code looks like this:
When I run the above code, it throws an OleDbException on the last line. However, if I change default_cmd_text to "select * from equipment_rates", then it works.
What am I missing here? The examples I've seen led me to believe that you could pass the Data Adapter an arbitrary SELECT query. Is that not the case?
I'm making a simple form to display data from an Access database. The relevant code looks like this:
Code:
Dim conn As OleDb.OleDbConnection
Dim da As OleDb.OleDbDataAdapter
Dim ds As DataSet
Dim conn_str As String
Dim default_cmd_text As String
conn_str = "Provider=Microsoft.Jet.OLEDB.4.0; Persist Security Info=False; Data Source=C:\mydb.mdb"
conn = New OleDb.OleDbConnection(conn_str)
default_cmd_text = "select rate_code, basic_rate, supplies, usage from equipment_rates"
da = New OleDb.OleDbDataAdapter(default_cmd_text, conn)
ds = New DataSet()
da.Fill(ds, "rate_codes")
What am I missing here? The examples I've seen led me to believe that you could pass the Data Adapter an arbitrary SELECT query. Is that not the case?