|
-
Sep 7th, 2003, 06:02 AM
#1
Thread Starter
Hyperactive Member
Query CSV data in Dataset
Hey All,
I have loaded CSV data into a dataset, but I'm not sure how to query this dataset with SQL, is it possible?
TIA.
_Dodger.
-
Sep 7th, 2003, 07:58 AM
#2
Frenzied Member
You do something like this
VB Code:
Dim rows() as DataRow = MyDS.Table("myTable").Select(SQL statement here)
Hope that helps.
-
Sep 7th, 2003, 09:10 AM
#3
Thread Starter
Hyperactive Member
Hi DevGrp,
Here is my code, it seems to be selecting the correct number of rows, but all data is null, I'm obviously doing something wrong (new to .NET). Please assist if you can.
Code:
Dim fxDataSet As New Data.DataSet()
Dim fxTable As New DataTable()
Dim fxFile As StreamReader = New StreamReader("C:\_Trading\History\25-06-03_02-09-03.txt")
With fxTable.Columns
.Add("Date")
.Add("Price")
End With
While fxFile.Peek <> -1
fxTable.Rows.Add(Split(fxFile.ReadLine, ",", , CompareMethod.Text))
End While
Dim rows() As DataRow = fxTable.Select("Units = ' 150'")
fxTable.Clear()
Dim i As Integer
For i = 0 To rows.GetUpperBound(0)
fxTable.Rows.Add(rows(i))
Next
fxDataSet.Tables.Add(fxTable)
DataGrid1.DataSource = fxDataSet
TextBox1.Text = fxDataSet.Tables(0).Rows.Count()
TIA.
_Dodger.
-
Sep 7th, 2003, 11:51 AM
#4
Frenzied Member
If you are doing it like that, then you can just use a DataView. I'll post some code when I get home.
-
Sep 7th, 2003, 03:17 PM
#5
Thread Starter
Hyperactive Member
Thanks DevGrp! I think I have it working correctly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|