| | |
problem for a simple asp.net query
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2005
Posts: 2
Reputation:
Solved Threads: 0
could any one plz help me for this query. i have tried a lot but only the first one is working. see my code:
(1)
CommandText = _
"SELECT sr.ResponseAnswerID, count(sr.RespondantID) from SURVEY_RESPONSE sr INNER JOIN ANSWER a on " _
& "sr.ResponseAnswerID=a.AnswerID where a.QuestionID= 284 " _
& "group by sr.ResponseAnswerID"
(2)
CommandText = _
"SELECT a.AnswerDescription, count(sr.RespondantID) from SURVEY_RESPONSE sr INNER JOIN ANSWER a on " _
& "sr.ResponseAnswerID=a.AnswerID where a.QuestionID= 284 " _
& "group by a.AnswerDescription"
------
for the first one it is working fine but displaying only its id. what i want is AnswerDescription instead of ResponseAnswerID.
the error for (2) is
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
i have tried a lot, using select in another select statement, having into, like.... but none is working
hope to have a quick response. thanks
antish
(1)
CommandText = _
"SELECT sr.ResponseAnswerID, count(sr.RespondantID) from SURVEY_RESPONSE sr INNER JOIN ANSWER a on " _
& "sr.ResponseAnswerID=a.AnswerID where a.QuestionID= 284 " _
& "group by sr.ResponseAnswerID"
(2)
CommandText = _
"SELECT a.AnswerDescription, count(sr.RespondantID) from SURVEY_RESPONSE sr INNER JOIN ANSWER a on " _
& "sr.ResponseAnswerID=a.AnswerID where a.QuestionID= 284 " _
& "group by a.AnswerDescription"
------
for the first one it is working fine but displaying only its id. what i want is AnswerDescription instead of ResponseAnswerID.
the error for (2) is
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
i have tried a lot, using select in another select statement, having into, like.... but none is working
hope to have a quick response. thanks
antish
•
•
Join Date: Mar 2005
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by tishr
could any one plz help me for this query. i have tried a lot but only the first one is working. see my code:
(1)
CommandText = _
"SELECT sr.ResponseAnswerID, count(sr.RespondantID) from SURVEY_RESPONSE sr INNER JOIN ANSWER a on " _
& "sr.ResponseAnswerID=a.AnswerID where a.QuestionID= 284 " _
& "group by sr.ResponseAnswerID"
(2)
CommandText = _
"SELECT a.AnswerDescription, count(sr.RespondantID) from SURVEY_RESPONSE sr INNER JOIN ANSWER a on " _
& "sr.ResponseAnswerID=a.AnswerID where a.QuestionID= 284 " _
& "group by a.AnswerDescription"
------
for the first one it is working fine but displaying only its id. what i want is AnswerDescription instead of ResponseAnswerID.
the error for (2) is
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
i have tried a lot, using select in another select statement, having into, like.... but none is working
hope to have a quick response. thanks
antish
You have any field in either table which is having a data type of text or ntext or image. If you used text or ntext field, please change the datatype to varchar and then try the query again.
All the best
Pallab
varchar has a maximum of 8000 bytes.
Another possible hack is
Another possible hack is
ASP Syntax (Toggle Plain Text)
SELECT some_field FROM some_table WHERE (some_text_field LIKE 'VALUE')
Do the aggregation in a subquery, then join on to the answer table from there to pull the description (Sql Datatypes text ntext and image can't be used in GROUP BY clauses)
ASP Syntax (Toggle Plain Text)
select oa.AnswerDescription, srCount from ( SELECT sr.ResponseAnswerID, count(sr.RespondantID) as srCount from SURVEY_RESPONSE sr INNER JOIN ANSWER a on sr.ResponseAnswerID=a.AnswerID where a.QuestionID= 284 group by sr.ResponseAnswerID ) sub join ANSWER oa on sub.ResponseAnswerID = oa.AnswerID
![]() |
Similar Threads
- Simple ASP.Net Login Page using C# (C#)
- Updated : Simple ASP.Net Login Page (ASP.NET)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
Other Threads in the ASP Forum
- Previous Thread: how to get network login user name
- Next Thread: How can i construct a database?
| Thread Tools | Search this Thread |
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection connection database databaseconnection dreamweaver excel fso iis msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption single specfic sqlserver sqlserverconnection windows7






