Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datarow string item removing CRLF 1

Status
Not open for further replies.

evaleah

Programmer
Mar 18, 2003
252
US
I am querying an Access database. One of the items returned is a memo field. When I look at the database the field has carriage returns. When I execute instr(DR.Item("Body"), ControlChars.NewLine) or ControlChars.Cr, ControlChars.Lf or ControlChars.CrLf it comes back with 0 every single time. Yes there it is in the db with carriage returns. I have this same routine in a VB6 app and it returns complete with the carriage returns still in there. Am I missing something?

Thanks!
Eva
 
Ok. Since you want to remove the carriage returns, you can try this:
Code:
'please note that t is a datatable
      For Each table_row As DataRow in t.Rows
         MsgBox(Replace(table_row("Body").ToString, Environment.NewLine, " "))
      Next

Or, if you use the DataReader:
Code:
      Dim s As String = ""
      While dr.Read
         s = dr(1).ToString
         MsgBox(s)
         MsgBox(Replace(s, Environment.NewLine, " "))
      End While
      dr.Close()

Hope this helps.
 
I ended up recoding to get around the issue but thanks for the tip. I am sure to use Environment next time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top