Classic ASP: RecordSet field gives no value

I'm not an ASP developer, so I lost a little.

I have the following data access code:

sSQL = "SELECT answer_id, company_name, old_access_company_name, answer, flag_asker_notified FROM Q01_ask_sheiiba_answer_company2 WHERE question_id="& sQuestion_id &" ORDER BY answer_id" rs.open sSQL, conn DO WHILE NOT rs.EOF Response.Write(rs.Fields("answer")) rs.MoveNext LOOP 

I tested that the SQL query was built correctly, outputting it in response before it was called. It issues the following query:

 SELECT answer_id, company_name, old_access_company_name, answer, flag_asker_notified FROM Q01_ask_sheiiba_answer_company2 WHERE question_id=988 ORDER BY answer_id 

When I copy this exact query to sql management studio and run it, I get the expected results from 5 rows and each row containing data in each cell, BUT, when I run it through the specified code, I get the same 5 rows with the same cell data, EXCEPT for the answer column, which is empty!

What am I missing?

Thank you in advance

+4
source share
4 answers

There are two things you can try:

Place the text box at the end of the query. For instance:

SELECT answer_id, company_name, old_access_company_name, flag_asker_notified, answer

If this does not give you results, you can try:

 WHILE NOT rs.EOF theanswer=rs("answer") Response.Write(theanswer) rs.movenext wend 

Text and memo fields can interfere with ASP.

EDIT . One more thing you can try:

 rs.CursorLocation = adUseClient 

or

 rs.CursorLocation = 3 
+6
source

The problem is that the ODBC driver cannot access large blocks of text as strings; you need to access them as chunked BLOB data .

Instead, I recommend that you disconnect the ODBC connection and connect directly using the OLE-DB driver . This will allow you to access this column as if it were just another varchar column.

+2
source

I had a similar problem (I think). I converted the varchar field to text. When I did this, I found that the text box seemed to β€œdisappear” from my selected recordset. In my case, I found that you can refer to the text box ONLY ONCE. After that, he seems to disappear. Accordingly, for a text field, now I just move it to a string variable, and then I operate on the string. This solved my problem.

John

+1
source

Had the same problem and found a solution here http://www.4guysfromrolla.com/aspfaqs/ShowFAQ.asp?FAQID=80
Basically, when you open a recordset (not connection.execute), use the adOpenKeyset (val 1) and adUseClient (val 3) parameters, and the text should be the last in your list of fields in strSql
Example: rs.Open strSql, dbConn, adOpenKeyset, adUseClient

0
source

All Articles