在sql表中处理存储为varbinary(max)的DATA FILE(文本)

时间:2022-08-28 09:25:08

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.

有一个包含10000个数字/数据点的数据文件(txt)。将数据文件存储为SQL表中的varbinary(MAX)。

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....

让DataReader直接在屏幕上显示数字没问题,但是我不知道如何将数字放入DataSet(或表格)来绘制图表....

Can anyone offer advice or give direction?

有人可以提供建议或指导吗?

Many thanks. Miry

非常感谢。溷

1 个解决方案

#1


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):

可能有一个更聪明的.Net方法来帮助你做到这一点,但是一个功能性的,如果是基本的方式,这样做(在VB .Net中 - 或者我的粗略近似):

'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.

这是基本的 - 一些错误处理将是一个好主意 - 但希望它会让你开始。

#1


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):

可能有一个更聪明的.Net方法来帮助你做到这一点,但是一个功能性的,如果是基本的方式,这样做(在VB .Net中 - 或者我的粗略近似):

'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.

这是基本的 - 一些错误处理将是一个好主意 - 但希望它会让你开始。