I'm having a problem and I've got the feeling it is something simple that I'm not doing right.
I've got a simple ASP.NET project going. I've got a DataSet that I populate from an Oracle database. The table in the DataSet has two columns: "account_code" and "account_descr".
The user enters in a search term into a textbox. I use LINQ to query to get the results from the DataSet and put them into another variable.
Then I try to bind the variable to the gridview.
Code:
Dim results = AccountsDataSet.Tables("Results")
Dim filteredResults = From q In results Where q.Item("account_code").ToString.StartsWith(search) Select q.Item("account_code")
GridView1.DataSource = filteredResults
GridView1.DataBind()
The code as above works. The only thing is it only shows the one column. I need it to show both columns. But if I change the LINQ line to this:
Dim filteredResults = From q In results Where q.Item("account_code").ToString.StartsWith(search) Select q.Item("account_code"), q.Item("account_descr")
it throws the error "Range variable name can be inferred only from a simple or qualified name with no arguments."
Any ideas?