Record source from database not retaining its original string format. Why?

Hello experts,

There is a field in my mysql database that contains an email response. It is text only and it has spaces and paragraphs.

Problem:

Whenever I retrieve this record and output it to a textbox it changes from:

line1
line2

line3
line4

line5

line6
line7
line8

...to:

line1 line2 line3 line4 line5 line6 line7 line8

Can you perhaps show me where the following code is going wrong?






Imports MySql.Data.MySqlClient
Public Class frmMain
 
    Public Const connstr As String = "server=mysqlserver1;user id=User;password=Password;database=xyz"
 
    Dim arrResponse As New ArrayList
 
    Private Sub tbxSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbxSearch.TextChanged
 
        lbxResponses.Items.Clear()
 
        LoadRemoteVersion()
 
    End Sub
 
    Sub LoadRemoteVersion()
 
        Dim conn As New MySqlConnection()
 
        'Try
 
        conn.ConnectionString = connstr
        conn.Open()
 
        Dim myCommand As New MySqlCommand
        Dim myReader As MySqlDataReader
 
        myCommand.Connection = conn
        myCommand.CommandText = "SELECT * FROM archresponses WHERE responsetitle LIKE '%" & tbxSearch.Text & "%' OR responsetext LIKE '%" & tbxSearch.Text & "%'"
 
        myReader = myCommand.ExecuteReader
 
        Dim counter As Integer = 0
 
        While myReader.Read
 
            counter += 1
            lbxResponses.Items.Add(myReader.GetValue(1))
            arrResponse.Add(myReader.GetValue(2))
 
        End While
 
        lblTotalResults.Text = counter
 
        'Catch
 
        'End Try
 
        conn.Close()
        conn.Dispose()
 
    End Sub
 
 
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
    End Sub
 
    Private Sub lbxResponses_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbxResponses.SelectedIndexChanged
 
        tbxResponse.Text = arrResponse(lbxResponses.SelectedIndex)
 
    End Sub
End Class

Open in new window

LVL 1
donniedarko801Asked:
Who is Participating?
 
CodeCruiserCommented:
It is because a text box can not display formatting. Try setting the multiline property to true to be able to show line breaks. Or else use a RichTextBox control.
0
 
donniedarko801Author Commented:
You know, my only regret is to only give you 50 points for this. Thanks man! Whish I had more points!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.