Ask a Question related to ASP Database, Design and Development.
-
Garfield #1
SQL statement working in SQL Server but not in .aspx.cs page
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 SQL statement is :
if (SqlConn.State == ConnectionState.Closed) SqlConn.Open();
sqlString ="SELECT
course_schedule.ScheduleID,coursename,startdate,en ddate,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
Garfield Guest
-
Accessing an .aspx page from server in a DMZ
We are currently hosting our own web site; the web site of course resides outside the DMZ. For security reasons, the network crew will not allow us... -
Accessing a aspx page using HttpWebRequest from another aspx page on the same webapp
Did you have any luck on this as I have the same problem. Maybe you can help me out of you solved your problem. -
Want to Reboot server from ASPX page
I am developing a asp.net web based service application for our product I am trying to trigger a reboot of the server based on a user request I... -
Calling a html page from an asp page then returning to the next statement on the original asp page
Hi! I have an ASP page that calls excel to create a report. This works fine. Now I need to call a html calendar page to filter what rows are... -
how to interact client script within aspx page to other page functions, etc.? PLEASE!!!
Hi, I've spent all day trying to find some info on this...please help! I have an aspx page with an xmlDocument (not dataset/relational db) with... -
Bob Barrows #2
Re: SQL statement working in SQL Server but not in .aspx.cs page
This is a classic asp newsgroup. While you may be lucky enough to find a
dotnet-savvy person here who can answer your question, you can eliminate the
luck factor by posting your question to an appropriate group. I suggest
microsoft.public.dotnet.framework.adonet.
Bob Barrows Guest
-
MS News \(MS ILM\) #3
Re: SQL statement working in SQL Server but not in .aspx.cs page
SELECTcourse_schedule. are you missing a blank here or Am I blind.
SELECT course_schedule.
"Garfield" <gboodie@hotmail.com> wrote in message
news:u2HZ8NDaDHA.2592@TK2MSFTNGP09.phx.gbl...ScheduleID)> 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> ,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
>
>
>
>
MS News \(MS ILM\) Guest
-
William \(Bill\) Vaughn #4
Re: SQL statement working in SQL Server but not in .aspx.cs page
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
[url]www.betav.com[/url]
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" <gboodie@hotmail.com> wrote in message
news:u2HZ8NDaDHA.2592@TK2MSFTNGP09.phx.gbl...ScheduleID)> 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> ,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 Guest
-
Garfield Boodie #5
Re: SQL statement working in SQL Server but not in .aspx.cs page
Thanks for your response. The query did work within
SQL Server, but I don't know what happeened.
I added a table Alais as suggested to my subquery
and that solved my problem.
Thanks
Garfield
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Garfield Boodie Guest



Reply With Quote

