Link to home
Start Free TrialLog in
Avatar of gianitoo
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 " 
 
Avatar of DBAduck - Ben Miller
DBAduck - Ben Miller
Flag of United States of America image

There has to be more to this than is shown.  What line is highlighted in the Source Error?

If Line 11: is all on one line, I don't see a broken line.

Ben
Avatar of gianitoo
gianitoo

ASKER

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ 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(JMIConnectionString)
   
      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(chart)
      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
Avatar of nauman_ahmed
nauman_ahmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
how do i opne that connection now i get this

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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial