views:

468

answers:

1

Hi, looking for help and need pointing in the right direction, can anyone assist?

Have a data file (txt) that contains 10000 numbers/data points. Storing the data file as varbinary(MAX) in an SQL table.

My goal is to retrieve the file on user request and plot/chart the numbers as a line chart.

No problem in getting DataReader to display the numbers directly to the screen, but I'm stuck as to how get the numbers into a DataSet (or table) to plot a chart....

Can anyone offer advice or give direction?

Many thanks. Miry

A: 

I'm assuming that the data points are delimited by new line characters when retrieved from the database.

There's probably a smarter .Net method to help you do it, but a functional, if basic, way of doing this would be something like (in VB .Net - or my rough approximation of it):

'create a new datatable
Dim myDT As New DataTable("DataPoints")

'add a column to the data table (assuming your data is integer)
myDT.Columns.Add("Point", System.Type.GetType("System.Int32"))

'split the string containing the points into an array
dim pointArray as string() = pointString.Split(vbcrlf)

'add the points to the data table
dim s as string
foreach s in pointArray
     myDT.Rows.Add(Int32.Parse(s))
next

This is basic - some error handling would be a good idea - but hopefully it'll get you started.

Ed Harper
Ed thanks you for responseThe data points are separated by a new line and data points are integers.The DataReader has now been converted to a string and shows up clearly in VS.Run into an additional problem, creating the DataTable with “myDT.Columns.Add("Point", System.Type.GetType("System.Integer"))” which throws an error - “System.ArgumentNullException: 'dataType' argument cannot be null. Parameter name: dataType”Scoured the web and the syntax appears correct and looks perfectly fine to me.Do you have any ideas as to why?Many thanks for your help getting me this far...Miry
miry
"System.Integer" should have been "System.Int32" - I've corrected my answer to reflect this.
Ed Harper
Ed, your a star, many thanksMiry
miry