?
Solved

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

Posted on 2008-11-18
2
Medium Priority
?
151 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:donniedarko801
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 200 total points
ID: 22994184
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
 
LVL 1

Author Closing Comment

by:donniedarko801
ID: 31518068
You know, my only regret is to only give you 50 points for this. Thanks man! Whish I had more points!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Integration Management Part 2
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question