[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

whats wrong with this SqlConnection

Posted on 2007-08-01
6
Medium Priority
?
557 Views
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 " 
 
0
Comment
Question by:gianitoo
6 Comments
 
LVL 25

Expert Comment

by:DBAduck - Ben Miller
ID: 19611324
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
 
LVL 1

Author Comment

by:gianitoo
ID: 19611334
<%@ 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
 
LVL 25

Accepted Solution

by:
nauman_ahmed earned 1000 total points
ID: 19611365
You need to take out () at the end of SQL statement.

--Nauman.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:gianitoo
ID: 19611378
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
 
LVL 9

Expert Comment

by:bele04
ID: 19611380
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
 
LVL 25

Assisted Solution

by:DBAduck - Ben Miller
DBAduck - Ben Miller earned 1000 total points
ID: 19611404
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

834 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