Link to home
Start Free TrialLog in
Avatar of donniedarko801
donniedarko801

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of donniedarko801
donniedarko801

ASKER

You know, my only regret is to only give you 50 points for this. Thanks man! Whish I had more points!