I want my DataSet query results to be transferred to an array.
Here is my query:
This is the only way I know to display the contents of my query: Trans_TableTableAdapter.SelectDistinct(DBDataSet.Trans_Table)
My problem is I don't know how to apply this query to an array.
This is the last piece of my puzzle, I really need help to complete my project. Thanks in advance.
So you want a String()
from the query that returns a single column? You can use LINQ:
Dim accounts As String() = DBDataSet.Trans_Table.AsEnumerable().
Select(Function(row) row.Field(Of String)("Account")).
ToArray()
If you prefer query syntax:
Dim accounts = From row In DBDataSet.Trans_Table.AsEnumerable()
Select row.Field(Of String)("Account")
Dim accountArray As String() = accounts.ToArray()
Since that seems to be a strongly typed DataSet
there should be a named column which you can use directly:
Dim accounts = From row In DBDataSet.Trans_Table Select row.Account
Dim accountArray As String() = accounts.ToArray()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.