Wrox Programmer Forums
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 11th, 2007, 02:55 PM
Authorized User
Join Date: Dec 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Incorrect Syntax Error.


Normally when you received this message is it coming from the db, or the code itself?

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near ')'.

Source Error:

Line 278: sqlConn.Open()
Line 279:
Line 280: dbread = sqlCmd.ExecuteReader()
Line 281:
Line 282: Do While dbread.Read()

Source File: E:\PwrDev\_calendars\calendar.aspx.vb Line: 280


 Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)

            'Dim calid As Integer = CInt(Page.Request.QueryString("calid"))
        Dim calid As String = 0

        If Page.IsPostBack Then
            calid = CalendarType.Value.ToString
            'CalendarType.SelectedValue = calid
            calid = Request.QueryString("calid")
        End If

        'If calendartype.Value = "" Then
        'If Not Page.Request.QueryString("calid") = "" Then
        'calid = Page.Request.QueryString("calid")
        'calid = CalendarType.Value
        'End If
        'calid = CalendarType.Value
        'End If

        calid_value.Text = calid
        calid_value_select.Text = CalendarType.Value.ToString

        Dim sqlConn As SqlConnection
        Dim sqlCmd As SqlCommand
        Dim strConnection As String
        Dim dbread As SqlDataReader
        Dim fieldcount As Integer
        Dim sql
        strConnection = ConfigurationManager.AppSettings("connectionString ")
        sqlConn = New SqlConnection(strConnection)

        Dim d As CalendarDay
        Dim c As TableCell
        Dim dbcomm
        Dim DayData
        Dim Color
        d = e.Day
        c = e.Cell
        Dim TheDate = d.Date.ToShortDateString
        current_date = TheDate

        If calid = "0" Then
            sql = "SELECT * FROM Calendar_Events WHERE ((Calendar_Events.StartDate <= '" & TheDate & "') AND (Calendar_Events.EndDate >= '" & TheDate & "')) ORDER BY Calendar_Events.StartDate, Calendar_Events.StartTime"
            sql_lbl.text = sql
            sql = "SELECT * FROM Calendar_Events WHERE (((Calendar_Events.StartDate <= '" & TheDate & "') AND (Calendar_Events.EndDate >= '" & TheDate & "')) AND (Calendar_Events.CalendarID=" & calid & ")) ORDER BY Calendar_Events.StartDate, Calendar_Events.StartTime"
            sql_lbl.text = sql
        End If

        sqlCmd = New SqlCommand(sql)
        sqlCmd.Connection = sqlConn

        dbread = sqlCmd.ExecuteReader()

        Do While dbread.Read()
            DayData = Left(dbread("Event"), 19) + "<br>"

            If IsMemberLoggedOn <> 1 Then

                If d.IsOtherMonth Then

                    'Color = dbread("Color")
                    c.Controls.Add(New LiteralControl("<br><a href=calendar.aspx?EventID=" & dbread("EventID") & "&calid=" & calid & ">" & DayData & "</a>"))
                End If

                'Color = dbread("Color")
                c.Controls.Add(New LiteralControl("<br><a href=calendar.aspx?EventID=" & dbread("EventID") & "&calid=" & calid & "&member_id=" & MemberId & "&IMS_Login=" & IMSLogin & "&IMS_Password=" & PrivateId & "&IsMemberLoggedOn=" & IsMemberLoggedOn & ">" & DayData & "</a>"))
            End If


        End Sub

The page consists of a calendar control and a combobox. when the user click on the item, they will see the event info on the side and there is a textbox where they can enter their e-mail to be reminded of the event. This should just postback to the same page and show the calendar again.

Any ideas would be great.


Old January 11th, 2007, 03:13 PM
Wrox Author
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

Sounds like a SQL Syntax error; print out your SQL Statements after you have populated them with variables and verifiy they are correct SQL Syntax.

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
Old January 12th, 2007, 01:33 AM
Authorized User
Join Date: Nov 2006
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to akhilhp

Is calid a character or numeric ? I can only see that calid should also be surrounded by ' ' Other wise in first sight nothing wrong apears with the Sql Statement. But again if calid is numeric u can always verify the sql statement as suggested by dparsons...

Similar Threads
Thread Thread Starter Forum Replies Last Post
Incorrect syntax near '.' meraj ADO.NET 6 February 27th, 2012 01:01 AM
Error: Line 8: Incorrect syntax near '.' ; Help! Fly4High SQL Server 2000 2 August 15th, 2006 03:02 AM
Incorrect syntax near '!' sinapra Classic ASP Databases 8 August 25th, 2004 02:15 AM
Incorrect syntax near '`' Hez Classic ASP Databases 3 August 5th, 2004 08:13 AM
Error Line 1: Incorrect syntax near '='. Calibus Classic ASP Databases 9 July 20th, 2004 02:22 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.