Click to See Complete Forum and Search --> : SQL data to populate graph prob


monsieurmark777
June 15th, 2009, 05:29 PM
Hi all,

Stumped on something, hopr you can help... I have created a function to create a string to populate a y axis with data:

Function talktosql() As Double
Dim ConnString As String = "Data Source=MARK-WORK\MSSMLBIZ;Initial Catalog=Yahoo_data;Integrated Security=True"
Dim SQLString As String = "SELECT [RDSA.L] FROM yahoo_data.dbo.XLON"
Dim SqlDataAdapter1 As New SqlDataAdapter(SQLString, ConnString)
Dim DataSet1 As New DataSet()
SqlDataAdapter1.Fill(DataSet1, "dataextotbl")
talktosql = Convert.ToDouble(DataSet1.Tables("dataextotbl").Co lumns("[RDSA.L]"))
MsgBox(talktosql)
End Function


the variable from the function, "talktosql", needs to be called from a sub into the last line from the sub extract below:

Sub creategraph()
Dim DataSeries As New Series
Dim DataSeries2 As New Series
Dim DataSeries3 As New Series
Dim DataSeries As New Series
Dim yValues As Double() = {talktosql()}

so it should for example come out like this:

Dim yValues As Double() = {55.62, 45.54, 73.45, 9.73, 88.42, 45.9, 63.6, 85.1, 67.2, 23.6}


I cannot seem to get the data from the function into the right format to populate "yvalues".

Any clue why? (the msgbox that I put in at the end in the first code renders the result "0")

Many thanks!

Mark

dglienna
June 15th, 2009, 06:41 PM
Take a look here (http://www.vb-helper.com/howto_getrows_arrays.html)

monsieurmark777
June 15th, 2009, 08:59 PM
Hi, thaks for the post, I'm using vb in visual studio 2008 so no go unfortunately on that link... cheers anyway

monsieurmark777
June 15th, 2009, 09:11 PM
in fact, another problem, i only seem to be getting one column and one row back from the sql database, in which there is [rdsa.l] written.

If I execute this directly in sql server 2005 i get 1000 rows... there must be a prob in the connection function too methinks...

dglienna
June 16th, 2009, 12:48 AM
This link? http://code.msdn.microsoft.com/vbsamples/

Title: Visual Basic 2008 Samples

monsieurmark777
June 16th, 2009, 03:53 AM
That looks like a great link, thanks! An enormous amount in it. Will have a dig around...