By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

Problems in getting a string value from a recordset

P: 28
I am using a recordset to retrieve values from a sql server database that I would want to display on an classic ASP page. It however seems that I cannot get a string value from the recordset. It just shows a blank space on the page that I want that value to appear. I have marked as bold the value that is supposed to have a string value in the code below. Please help me out and let me know what I could be missing. I am working with VBScript.

Expand|Select|Wrap|Line Numbers
  1. Dim objNotesConn
  2. Dim objNotesCommand
  3. Dim objNotesRecordset
  4.  
  5. dim intNoteUserID
  6. dim intNoteModByUserID
  7. dim intNotesID
  8. dim strObjCityCareNote
  9. dim datNoteDateCreated
  10. dim datNoteDateModified
  11.  
  12. ' Create the connection objNotesRecordset.
  13.  
  14. Set objNotesConn = Server.Createobject("ADODB.Connection")
  15. objNotesConn.Open Application("ConnStr")
  16.  
  17. ' Execute pe_selectCityCareNotes1.
  18.  
  19. Set objNotesCommand = Server.Createobject("ADODB.Command")
  20. objNotesCommand.ActiveConnection = objNotesConn
  21. objNotesCommand.CommandType = adcmdStoredProc
  22. objNotesCommand.CommandText = "pe_selectCityCareNotes1"
  23. objNotesCommand.Parameters.append objCommand.createParameter("intPersonID", adInteger, adParamInput)
  24.  
  25. objNotesCommand.Parameters("intPersonID") = intPersonID
  26.  
  27. Set objNotesRecordset = objNotesCommand.Execute        
  28.  
  29. Set intNotesID          = objNotesRecordset(0)
  30. Set datNoteDateCreated  = objNotesRecordset(1)
  31. Set datNoteDateModified = objNotesRecordset(3)
  32. Set strObjCityCareNote  = objNotesRecordset(2)
  33. Set intNoteModByUserID  = objNotesRecordset(4)
  34. Set intNoteUserID       = objNotesRecordset(5)
  35.  
  36. if intNoteID <>"" then
  37. compareDates = DateDiff("d",datNoteDateModified,Date())
  38. end if
  39.  
Expand|Select|Wrap|Line Numbers
  1. If Not objNotesRecordset.EOF Then
  2.                     %>
  3.                     <%
  4.         Do While Not objNotesRecordset.EOF
  5.                     %>
  6.                     <tr>
  7.                         <td class="inputlabel" colspan="1">
  8.                             City Care Note
  9.                             <br />
  10.                             <%  
  11.                             If Len(strObjCityCareNote) > 0 then 
  12.                             %>
  13.                             <b>
  14.                                 <%Call displayDate(datNoteDateCreated, "-", "MM:HH XM DD MMM YYYY")%></b>
  15.                             <br />
  16.                             <br />
  17.                             <%End if %>
  18.                         </td>
  19.                         <td id="demo" class="note" colspan="2">
  20.                             <%  
  21.                             If Len(strObjCityCareNote) <> "" then 
  22.                             %>
  23.                             <b>
  24.                                 <% Call displayString(strObjCityCareNote,"-")%>
  25.                                 &nbsp;&nbsp;&nbsp;&nbsp;[<%Call displayString(strUserFirstName,"") %>&nbsp; &nbsp;<% Call displayString(strUserSurname,"")%>&nbsp;]</b>
  26.                             <% End If %>
  27.                             <%
  28.             objNotesRecordset.MoveNext
  29.         Loop
  30.  
Apr 12 '12 #1
Share this Question
Share on Google+
7 Replies


Rabbit
Expert Mod 10K+
P: 12,369
That's because you call a function displaystring that isn't defined in your code. And you use a variable that is not populated. Either that or you left out code that is relevant.
Apr 12 '12 #2

P: 28
Hi, I am sorry i did not include the code for the displayString() function. The function works well and if I put a 3 instead of a 2 so that the line:
Set strObjCityCareNote = objNotesRecordset(2) becomes:

Set strObjCityCareNote = objNotesRecordset(3),
I get a date displayed on my ASP page. So I am sure that the recordset does have some values in it.
Apr 12 '12 #3

ck9663
Expert 2.5K+
P: 2,878
Try converting the value to string either in your back-end or handle it on your ASP.

Good Luck!!!


~~ CK
Apr 13 '12 #4

P: 28
let me try that. I will get back to you
Apr 13 '12 #5

P: 28
Seems it was a problem with the column in my database that was being used to populate the strObjCityCareNote value. I had created it as varchar(max) column and apparently I was supposed to put a value such a varchar(500).

Is it possible to get the row id's for the rows in my recordset?
Apr 17 '12 #6

ck9663
Expert 2.5K+
P: 2,878
Why do you need the row id? Records in sql server is not always stored sequentially...

Happy Coding!!!


~~ CK
Apr 19 '12 #7

P: 28
I need to edit the notes for a person's profile that is pulled from the database. The problem is that when a person has multiple notes, I can only view and edit the last note.
Apr 20 '12 #8

Post your reply

Sign in to post your reply or Sign up for a free account.