Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: SQL statement working in SQL Server but not in .aspx.cs page

Reply
Thread Tools

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

 
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      08-21-2003
Shouldn't
sqlString
="SELECTcourse_schedule.ScheduleID,coursename,star tdate,enddate,ctr FROM
be
sqlString
="SELECT course_schedule.ScheduleID,coursename,startdate,en ddate,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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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,star tdate,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
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com ASP .Net 0 05-03-2008 12:43 PM
response.redirect is not working but server.transfer is working gaurav tyagi ASP .Net 14 01-20-2006 04:22 AM
asp and sql statement in sql server db weiwei ASP General 3 09-22-2004 04:12 PM
Dateadd in SQL statement not working Brandon ASP General 9 05-10-2004 11:00 PM
Re: SQL statement working in SQL Server but not in .aspx.cs page David Browne ASP .Net 0 08-21-2003 10:43 PM



Advertisments