 |

07-19-2012, 03:40 AM
|
|
Newcomer
|
|
Join Date: Mar 2009
Posts: 8
|
|
How do i use new line or tab in sql DB with visual basic 2010
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..
TIA
Last edited by LymX : 07-19-2012 at 04:19 AM.
|

07-23-2012, 06:23 PM
|
 |
i am a guy ok?? -.-
|
|
Join Date: Nov 2006
Location: Canada
Posts: 5,232
|
|
Re: How do i use new line or tab in sql DB with visual basic 2010
Use vbCrLf
|

07-25-2012, 12:09 AM
|
 |
When They Cry...
|
|
Join Date: Jan 2007
Location: Japan
Posts: 4,404
|
|
Re: How do i use new line or tab in sql DB with visual basic 2010
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
__________________
Quote:
[14:54:13] <&Filefragg> x9 is made of 5 glow in the dark gorilla dildos vibrating in unison.
[14:54:19] <%TDD> hot
[14:54:22] <+Aoi> Win
[14:54:23] <x9> I TOLD YOU NOT TO TELL ANYONE, DAMNIT
|
|

07-26-2012, 07:47 AM
|
 |
i am a guy ok?? -.-
|
|
Join Date: Nov 2006
Location: Canada
Posts: 5,232
|
|
Re: How do i use new line or tab in sql DB with visual basic 2010
Quote:
Originally Posted by Swan
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.
|

07-26-2012, 09:38 PM
|
 |
Apprentice
|
|
Join Date: Mar 2008
Location: Belgium
Posts: 675
|
|
Re: How do i use new line or tab in sql DB with visual basic 2010
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.
__________________
I make private osrs scripts for tribot - PM me

|

07-27-2012, 01:57 AM
|
 |
i am a guy ok?? -.-
|
|
Join Date: Nov 2006
Location: Canada
Posts: 5,232
|
|
Re: How do i use new line or tab in sql DB with visual basic 2010
Quote:
Originally Posted by mercatres
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.
|

07-27-2012, 05:39 AM
|
 |
When They Cry...
|
|
Join Date: Jan 2007
Location: Japan
Posts: 4,404
|
|
Re: How do i use new line or tab in sql DB with visual basic 2010
Quote:
Originally Posted by Blupig
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.
__________________
Quote:
[14:54:13] <&Filefragg> x9 is made of 5 glow in the dark gorilla dildos vibrating in unison.
[14:54:19] <%TDD> hot
[14:54:22] <+Aoi> Win
[14:54:23] <x9> I TOLD YOU NOT TO TELL ANYONE, DAMNIT
|
|

07-27-2012, 06:31 PM
|
 |
i am a guy ok?? -.-
|
|
Join Date: Nov 2006
Location: Canada
Posts: 5,232
|
|
Re: How do i use new line or tab in sql DB with visual basic 2010
Quote:
Originally Posted by Swan
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:

|

07-29-2012, 02:04 PM
|
 |
Apprentice
|
|
Join Date: Apr 2011
Posts: 887
|
|
Re: How do i use new line or tab in sql DB with visual basic 2010
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;
__________________

Thanks to Exapto for it! ^
Scammers banned: 4.
|

07-31-2012, 04:07 AM
|
|
Newcomer
|
|
Join Date: Mar 2009
Posts: 8
|
|
Re: How do i use new line or tab in sql DB with visual basic 2010
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.
|
 |
|