• Log in or sign up for an account here: https://www.sythe.org/login

How do i use new line or tab in sql DB with visual basic 2010

LymX

Newcomer
Joined
Mar 19, 2009
Sythe Gold
10
Messages
16
Hi, I would like to insert table of contents into the DB and show it in form with only 1 label. All text are in one field of database only. The text should include new lines.
something like:
------------------
"Table of Contents

Introduction
Background tabgoeshere 2-1​
Objective tabgoeshere 2-2​
"
------------------

I am using varchar(max) and this is what i got so far..

53a6f3745b.png


TIA
 
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
Member of the Month Winner
Sythe's 10th Anniversary
Use escape characters; characters preceded by a backslash that have a specific function.

For newline, the escape character is '\n' - Just insert it where you want a newline. As for tabspace, it's '\t'. Well, I'm speaking as a C programmer but I should assume VB will accept it being part of .Net.

Here's a list of them for you: http://msdn.microsoft.com/en-us/library/h21280bw.aspx
 
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
Use escape characters; characters preceded by a backslash that have a specific function.

For newline, the escape character is '\n' - Just insert it where you want a newline. As for tabspace, it's '\t'. Well, I'm speaking as a C programmer but I should assume VB will accept it being part of .Net.

Here's a list of them for you: http://msdn.microsoft.com/en-us/library/h21280bw.aspx

To my knowledge VB doesn't accept them because it has its own set of characters, like vbTab, vbCr, vbLf, vbNewLine, etc.
 
Try using nvarchar or text.
What database are you using? MSSQL?
NCHAR(13) is a MSSQL command that should return an enter.

However I use MySQL and it stores it just fine.
 
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
Try using nvarchar or text.
What database are you using? MSSQL?
NCHAR(13) is a MSSQL command that should return an enter.

However I use MySQL and it stores it just fine.

Yeah this should work if you're executing your queries right away. If you're assembling them as strings though, use vbCrLf.
 
Member of the Month Winner
Sythe's 10th Anniversary
To my knowledge VB doesn't accept them because it has its own set of characters, like vbTab, vbCr, vbLf, vbNewLine, etc.

I thought that may be the case but I haven't used VB in a long time. I'd wonder about it though because it's a part of .Net so it may be capable of parsing escape chars.
 
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
I thought that may be the case but I haven't used VB in a long time. I'd wonder about it though because it's a part of .Net so it may be capable of parsing escape chars.

I didn't actually test it before, but I suppose it doesn't work after seeing this:

Mdbp
 
Hmm strange it doesn't accept. I only code in visual studio 2010 so meh.
Try: "\n" if that really doesn't work you could also try
Environment.NewLine;
 
Hey guys thanks for the replies. The problem is because i copy the data from a notepad and insert it directly to the database (service based database) and when i paste it the database doesn't accept new line but when i made a richtextbox paste the data in there and save it to database it worked. Thanks guys.
 
Back
Top