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 " 
 
LVL 1
gianitooAsked:
Who is Participating?
 
nauman_ahmedConnect With a Mentor Commented:
You need to take out () at the end of SQL statement.

--Nauman.
0
 
DBAduck - Ben MillerPrincipal ConsultantCommented:
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
0
 
gianitooAuthor Commented:
<%@ 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" />
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
gianitooAuthor Commented:
how do i opne that connection now i get this

ExecuteReader requires an open and available Connection. The connection's current state is closed.
0
 
bele04Commented:
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
0
 
DBAduck - Ben MillerConnect With a Mentor Principal ConsultantCommented:
You should have the connection open before executing anything against it.

      Dim myCommand as New SqlCommand(strSQL, myConnection)
myConnection.Open()
      Dim reader as SqlDataReader = myCommand.ExecuteReader()      
     
Ben
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.