Hi All,
I am trying to create a simple bar chart using ASP.net and after searching online i got a sample code which does this with static data...but i want to fetch the data from my SQL database and not sure of how to change this below piece of code to populate the dynamic data from DB...
Any help would be appreciated...
Thanks in advance...
-VJ
i tried something like this .....
created a db connection string, a data reader and looping thru the data but it didnt work...
Dim connString As String = "Data Source = STJSQL\STJDB; Database=STJData;User ID=xxxx;Password=xxxx"
Dim sql As String = "my sql string"
Dim conn As SqlConnection = New SqlConnection(connString)
Dim command As SqlCommand = New SqlCommand(sql, conn)
conn.Open()
Dim ReaderObj As SqlDataReader = command.ExecuteReader()
Do While ReaderObj.Read()
I am trying to create a simple bar chart using ASP.net and after searching online i got a sample code which does this with static data...but i want to fetch the data from my SQL database and not sure of how to change this below piece of code to populate the dynamic data from DB...
Any help would be appreciated...
Thanks in advance...
-VJ
Code:
void Page_Load(Object sender, EventArgs e) {
// Declare our variables
String [] sItems = new String[10];
Int32 [] iValue = new Int32 [10];
// Populate our variables
sItems[0] = "Carrots";
iValue[0] = 23;
sItems[1] = "Peas";
iValue[1] = 53;
sItems[2] = "Celery";
iValue[2] = 11;
sItems[3] = "Onions";
iValue[3] = 21;
sItems[4] = "Radishes";
iValue[4] = 43;
// Set our axis values
dngchart.YAxisValues = iValue;
// Set our axis strings
dngchart.YAxisItems = sItems;
}
i tried something like this .....
created a db connection string, a data reader and looping thru the data but it didnt work...
Dim connString As String = "Data Source = STJSQL\STJDB; Database=STJData;User ID=xxxx;Password=xxxx"
Dim sql As String = "my sql string"
Dim conn As SqlConnection = New SqlConnection(connString)
Dim command As SqlCommand = New SqlCommand(sql, conn)
conn.Open()
Dim ReaderObj As SqlDataReader = command.ExecuteReader()
Do While ReaderObj.Read()