gianitoo
asked on
whats wrong with this SqlConnection
Compiler Error Message: BC32017: Comma, ')', or a valid expression continuation expected.
Source Error:
Line 7: If Not Page.IsPostBack then
Line 8: 'STEP 1: Get the data from the database
Line 9: Dim myConnection as New SqlConnection(Connection String)
Line 10:
Line 11: Const strSQL as String = "SELECT purchasedhardware, COUNT(*) AS count FROM schlage GROUP BY purchasedhardware "
Source Error:
Line 7: If Not Page.IsPostBack then
Line 8: 'STEP 1: Get the data from the database
Line 9: Dim myConnection as New SqlConnection(Connection String)
Line 10:
Line 11: Const strSQL as String = "SELECT purchasedhardware, COUNT(*) AS count FROM schlage GROUP BY purchasedhardware "
ASKER
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Sql Client" %>
<%@ register tagprefix="web" namespace="WebChart" assembly="WebChart"%>
<script runat="server" language="VB">
Sub Page_Load(sender as Object, e as EventArgs)
If Not Page.IsPostBack then
'STEP 1: Get the data from the database
Dim myConnection as New SqlConnection(JMIConnectio nString)
Const strSQL as String = "SELECT purchasedhardware, COUNT(*) AS count FROM schlage GROUP BY purchasedhardware () "
Dim myCommand as New SqlCommand(strSQL, myConnection)
Dim reader as SqlDataReader = myCommand.ExecuteReader()
'STEP 2: Create the chart object
Dim chart as New PieChart
'STEP 3: Bind the DataTable to the WebChart
chart.DataSource = reader
chart.DataXValueField = "purchasedhardware"
chart.DataYValueField = "count"
chart.DataBind()
chart.DataLabels.Visible = True
'STEP 4: Attach the chart object to the chart container
ChartControl1.Charts.Add(c hart)
ChartControl1.RedrawChart( )
reader.Close()
myConnection.Close()
End If
End Sub
</script>
<web:chartcontrol runat="server" id="ChartControl1"
height="400" width="350" gridlines="none" legend-position="Bottom" />
<%@ Import Namespace="System.Data.Sql
<%@ register tagprefix="web" namespace="WebChart" assembly="WebChart"%>
<script runat="server" language="VB">
Sub Page_Load(sender as Object, e as EventArgs)
If Not Page.IsPostBack then
'STEP 1: Get the data from the database
Dim myConnection as New SqlConnection(JMIConnectio
Const strSQL as String = "SELECT purchasedhardware, COUNT(*) AS count FROM schlage GROUP BY purchasedhardware () "
Dim myCommand as New SqlCommand(strSQL, myConnection)
Dim reader as SqlDataReader = myCommand.ExecuteReader()
'STEP 2: Create the chart object
Dim chart as New PieChart
'STEP 3: Bind the DataTable to the WebChart
chart.DataSource = reader
chart.DataXValueField = "purchasedhardware"
chart.DataYValueField = "count"
chart.DataBind()
chart.DataLabels.Visible = True
'STEP 4: Attach the chart object to the chart container
ChartControl1.Charts.Add(c
ChartControl1.RedrawChart(
reader.Close()
myConnection.Close()
End If
End Sub
</script>
<web:chartcontrol runat="server" id="ChartControl1"
height="400" width="350" gridlines="none" legend-position="Bottom" />
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
how do i opne that connection now i get this
ExecuteReader requires an open and available Connection. The connection's current state is closed.
ExecuteReader requires an open and available Connection. The connection's current state is closed.
I'm not sure but at line 9 is that supposed to be "Connection String"?
Could you post more of the code at that area? probably a few lines down after line 11
Could you post more of the code at that area? probably a few lines down after line 11
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If Line 11: is all on one line, I don't see a broken line.
Ben