Problems in getting a string value from a recordset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rettla
    New Member
    • Jan 2012
    • 28

    Problems in getting a string value from a recordset

    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.

    Code:
    Dim objNotesConn
    Dim objNotesCommand
    Dim objNotesRecordset
    
    dim intNoteUserID
    dim intNoteModByUserID
    dim intNotesID
    dim strObjCityCareNote
    dim datNoteDateCreated
    dim datNoteDateModified
    
    ' Create the connection objNotesRecordset.
    
    Set objNotesConn = Server.Createobject("ADODB.Connection")
    objNotesConn.Open Application("ConnStr")
    
    ' Execute pe_selectCityCareNotes1.
      
    Set objNotesCommand = Server.Createobject("ADODB.Command")
    objNotesCommand.ActiveConnection = objNotesConn
    objNotesCommand.CommandType = adcmdStoredProc
    objNotesCommand.CommandText = "pe_selectCityCareNotes1"
    objNotesCommand.Parameters.append objCommand.createParameter("intPersonID", adInteger, adParamInput)
    
    objNotesCommand.Parameters("intPersonID") = intPersonID
    
    Set objNotesRecordset = objNotesCommand.Execute        
    
    Set intNotesID          = objNotesRecordset(0)
    Set datNoteDateCreated  = objNotesRecordset(1)
    Set datNoteDateModified = objNotesRecordset(3)
    [B]Set strObjCityCareNote  = objNotesRecordset(2)[/B]
    Set intNoteModByUserID  = objNotesRecordset(4)
    Set intNoteUserID       = objNotesRecordset(5)
    
    if intNoteID <>"" then
    compareDates = DateDiff("d",datNoteDateModified,Date())
    end if
    Code:
    If Not objNotesRecordset.EOF Then
                        %>
                        <%
            Do While Not objNotesRecordset.EOF
                        %>
                        <tr>
                            <td class="inputlabel" colspan="1">
                                City Care Note
                                <br />
                                <%  
                                If Len(strObjCityCareNote) > 0 then 
                                %>
                                <b>
                                    <%Call displayDate(datNoteDateCreated, "-", "MM:HH XM DD MMM YYYY")%></b>
                                <br />
                                <br />
                                <%End if %>
                            </td>
                            <td id="demo" class="note" colspan="2">
                                <%  
                                If Len(strObjCityCareNote) <> "" then 
                                %>
                                <b>
                                    <% Call displayString(strObjCityCareNote,"-")%>
                                    &nbsp;&nbsp;&nbsp;&nbsp;[<%Call displayString(strUserFirstName,"") %>&nbsp; &nbsp;<% Call displayString(strUserSurname,"")%>&nbsp;]</b>
                                <% End If %>
                                <%
                objNotesRecordset.MoveNext
            Loop
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    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.

    Comment

    • Rettla
      New Member
      • Jan 2012
      • 28

      #3
      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 strObjCityCareN ote = objNotesRecords et(2) becomes:

      Set strObjCityCareN ote = objNotesRecords et(3),
      I get a date displayed on my ASP page. So I am sure that the recordset does have some values in it.

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        Try converting the value to string either in your back-end or handle it on your ASP.

        Good Luck!!!


        ~~ CK

        Comment

        • Rettla
          New Member
          • Jan 2012
          • 28

          #5
          let me try that. I will get back to you

          Comment

          • Rettla
            New Member
            • Jan 2012
            • 28

            #6
            Seems it was a problem with the column in my database that was being used to populate the strObjCityCareN ote 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?

            Comment

            • ck9663
              Recognized Expert Specialist
              • Jun 2007
              • 2878

              #7
              Why do you need the row id? Records in sql server is not always stored sequentially...

              Happy Coding!!!


              ~~ CK

              Comment

              • Rettla
                New Member
                • Jan 2012
                • 28

                #8
                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.

                Comment

                Working...