Update of text field removing Cr Lf

  • I have a query that replaces the contents of a text field. The new contents includes carrage return and linefeed characters. When I look at the field after the update, it appears the carriage return and linefeeds are being replaced by blanks. Anyone have an idea as to why this might be happening? The update is being done using a command object in .Net. Here's the code:

    Dim rdr As SqlDataReader

    Dim alertNotes As String

    cmd.CommandText = "Select Notes From PatientTable " & _

    "Where PatientId = " & _

    "(Select PatientID From PatientVisitTable " & _

    "Where TicketNumber = '" & ticketNumber & "')"

    rdr = cmd.ExecuteReader()

    If rdr.HasRows Then

    rdr.Read()

    alertNotes = rdr.Item("Notes")

    rdr.Close()

    alertNotes = "Test Account " & Me.mtbPhone.Text & ControlChars.CrLf & alertNotes

    cmd.CommandText = "Update PatientTable " & _

    "Set Notes = '" & alertNotes & "' " & _

    "Where PatientId = " & _

    "(Select PatientID From PatientVisitTable " & _

    "Where TicketNumber = '" & ticketNumber & "')"

    rowsAffected = cmd.ExecuteNonQuery()

    If rowsAffected > 0 Then

    profileCnt += 1

    Else

    nomatchProfileCnt += 1

    End If

    Else

    rdr.Close()

    End If

    Thanks!!

  • If you're looking at it in the grid mode, then it will look as if the CrLf's are blanks... try looking at it in the text mode.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply