dbTalk Databases Forums  

Why doesn't this work? ASP -> SQL Server 2008 Select Distinct

microsoft.public.sqlserver.clients microsoft.public.sqlserver.clients


Discuss Why doesn't this work? ASP -> SQL Server 2008 Select Distinct in the microsoft.public.sqlserver.clients forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mark B
 
Posts: n/a

Default Why doesn't this work? ASP -> SQL Server 2008 Select Distinct - 07-29-2009 , 05:32 AM






This is in an ASP script, as I try to get unique classcodes
(StudentClassCode column) in the StudentData table.

Doesn't matter what I try in ASP, it stubbornly says Incorrect syntax near
the keyword 'Select'.

And yet this works fine in the MS SQL Server 2008 Querier console:

SELECT distinct [StudentClassCode]
FROM [StudentTimetable].[dbo].[StudentData] Order By StudentClassCode ASC

Ok, so there's a bit extra there, but even pasting this above in to the ASP
doesn't work!

Liddlebittahelp, please.

Thanks all,

Mark


<%

Dim conn
Dim rs
Dim cst

cst="Provider=SQLOLEDB.1;Data Source=myServer;Initial
Catalog=StudentTimetable;Network=DBMSSOCN;User Id=myID;password=myPW"
set conn=CreateObject("ADODB.Connection")
Set rs=Server.CreateObject("ADODB.Recordset")
conn.Open cst

rs.Open "Select distinct StudentClassCode FROM StudentData Order By
StudentClassCode ASC", conn, 1, 3, 2

rs.movefirst

Do while not rs.eof

response.write rs.fields("StudentClassCode")

rs.movenext

Loop

rs.close

conn.close

%>

Reply With Quote
  #2  
Old   
Mark B
 
Posts: n/a

Default Re: Why doesn't this work? ASP -> SQL Server 2008 Select Distinct - 07-29-2009 , 06:30 AM






Phew! Fixed it.

There was an issue with my connectivity string.


"Mark B" <marximus27 (AT) hotmail (DOT) com> wrote

Quote:
This is in an ASP script, as I try to get unique classcodes
(StudentClassCode column) in the StudentData table.

Doesn't matter what I try in ASP, it stubbornly says Incorrect syntax near
the keyword 'Select'.

And yet this works fine in the MS SQL Server 2008 Querier console:

SELECT distinct [StudentClassCode]
FROM [StudentTimetable].[dbo].[StudentData] Order By StudentClassCode ASC

Ok, so there's a bit extra there, but even pasting this above in to the
ASP doesn't work!

Liddlebittahelp, please.

Thanks all,

Mark


%

Dim conn
Dim rs
Dim cst

cst="Provider=SQLOLEDB.1;Data Source=myServer;Initial
Catalog=StudentTimetable;Network=DBMSSOCN;User Id=myID;password=myPW"
set conn=CreateObject("ADODB.Connection")
Set rs=Server.CreateObject("ADODB.Recordset")
conn.Open cst

rs.Open "Select distinct StudentClassCode FROM StudentData Order By
StudentClassCode ASC", conn, 1, 3, 2

rs.movefirst

Do while not rs.eof

response.write rs.fields("StudentClassCode")

rs.movenext

Loop

rs.close

conn.close

%

Reply With Quote
  #3  
Old   
Uri Dimant
 
Posts: n/a

Default Re: Why doesn't this work? ASP -> SQL Server 2008 Select Distinct - 07-29-2009 , 06:33 AM



Mark
What if you warp this script within a srored procedure and call it from
the ASP client does that work?


"Mark B" <marximus27 (AT) hotmail (DOT) com> wrote

Quote:
This is in an ASP script, as I try to get unique classcodes
(StudentClassCode column) in the StudentData table.

Doesn't matter what I try in ASP, it stubbornly says Incorrect syntax near
the keyword 'Select'.

And yet this works fine in the MS SQL Server 2008 Querier console:

SELECT distinct [StudentClassCode]
FROM [StudentTimetable].[dbo].[StudentData] Order By StudentClassCode ASC

Ok, so there's a bit extra there, but even pasting this above in to the
ASP doesn't work!

Liddlebittahelp, please.

Thanks all,

Mark


%

Dim conn
Dim rs
Dim cst

cst="Provider=SQLOLEDB.1;Data Source=myServer;Initial
Catalog=StudentTimetable;Network=DBMSSOCN;User Id=myID;password=myPW"
set conn=CreateObject("ADODB.Connection")
Set rs=Server.CreateObject("ADODB.Recordset")
conn.Open cst

rs.Open "Select distinct StudentClassCode FROM StudentData Order By
StudentClassCode ASC", conn, 1, 3, 2

rs.movefirst

Do while not rs.eof

response.write rs.fields("StudentClassCode")

rs.movenext

Loop

rs.close

conn.close

%

Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.