Re: SQL statement working in SQL Server but not in .aspx.cs page

Discussion in 'ASP .Net' started by William \(Bill\) Vaughn, Aug 21, 2003.

  1. Shouldn't
    sqlString
    ="SELECTcourse_schedule.ScheduleID,coursename,startdate,enddate,ctr FROM
    be
    sqlString
    ="SELECT course_schedule.ScheduleID,coursename,startdate,enddate,ctr FROM

    Of course, if this was a SP, you would not have this problem... ;)
    --
    ____________________________________
    Bill Vaughn
    MVP, hRD
    www.betav.com
    Please reply only to the newsgroup so that others can benefit.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    __________________________________

    "Garfield" <> wrote in message
    news:...
    > I have written the following query with a subquery to add a counter to be
    > added to a drop down list, which works in SQL Server, but when I transfer
    > the statement into my .aspx page it doesn't.
    >
    > I keep on getting the error : Line 1: Incorrect syntax near ','.
    >
    > The section of code with the SQL statement is :
    >
    > if (SqlConn.State == ConnectionState.Closed) SqlConn.Open();
    >
    > sqlString
    > ="SELECTcourse_schedule.ScheduleID,coursename,startdate,enddate,ctr FROM
    > course_schedule," +
    > "(SELECT count(*) as ctr,ScheduleID FROM TraineeCourses GROUP BY

    ScheduleID)
    > ,courses " +
    > "WHERE course_schedule.ScheduleID = TraineeCourses.ScheduleID AND
    > course_schedule.CourseID = courses.CourseID";
    >
    > SqlCommand cmdGetCourses = new SqlCommand(sqlString,SqlConn);
    > SqlDataReader readCourses = cmdGetCourses.ExecuteReader();
    >
    > while (readCourses.Read())
    > {
    > ListItem NewItem = new ListItem();
    > NewItem.Text = readCourses.GetString(1).ToString() + " : " +
    >
    > readCourses.GetDateTime(2).ToShortDateString() + " to " +
    >
    > readCourses.GetDateTime(3).ToShortDateString() + " : Places (" +
    > readCourses.GetValue(4).ToString() + ")";
    >
    > NewItem.Value = readCourses.GetValue(0).ToString();
    > this.drpCourses.Items.Add(NewItem);
    > }
    > readCourses.Close();
    >
    >
    > And I cannot see where the problem lies. Can somebody help?
    >
    > Regards
    > Garfield
    >
    >
    >
    >
     
    William \(Bill\) Vaughn, Aug 21, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Browne
    Replies:
    0
    Views:
    468
    David Browne
    Aug 21, 2003
  2. gaurav tyagi
    Replies:
    14
    Views:
    1,352
    gaurav tyagi
    Jan 20, 2006
  3. David Wang
    Replies:
    0
    Views:
    744
    David Wang
    Dec 1, 2006
  4. Brandon

    Dateadd in SQL statement not working

    Brandon, May 7, 2004, in forum: ASP General
    Replies:
    9
    Views:
    400
    Brandon
    May 11, 2004
  5. weiwei

    asp and sql statement in sql server db

    weiwei, Sep 22, 2004, in forum: ASP General
    Replies:
    3
    Views:
    212
    Jeff Cochran
    Sep 22, 2004
Loading...

Share This Page