whats wrong with this SqlConnection

Posted on 2007-08-01
Last Modified: 2008-01-09
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 "
Question by:gianitoo
    LVL 24

    Expert Comment

    by:DBAduck - Ben Miller
    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.

    LVL 1

    Author Comment

    <%@ 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.DataLabels.Visible = True
          'STEP 4: Attach the chart object to the chart container
        End If      
      End Sub


    <web:chartcontrol runat="server" id="ChartControl1"
         height="400" width="350" gridlines="none" legend-position="Bottom" />
    LVL 25

    Accepted Solution

    You need to take out () at the end of SQL statement.

    LVL 1

    Author Comment

    how do i opne that connection now i get this

    ExecuteReader requires an open and available Connection. The connection's current state is closed.
    LVL 9

    Expert Comment

    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
    LVL 24

    Assisted Solution

    by:DBAduck - Ben Miller
    You should have the connection open before executing anything against it.

          Dim myCommand as New SqlCommand(strSQL, myConnection)
          Dim reader as SqlDataReader = myCommand.ExecuteReader()      

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now