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

Discussion in 'Programming General' started by LymX, Jul 18, 2012.

How do i use new line or tab in sql DB with visual basic 2010
  1. Unread #1 - Jul 18, 2012 at 10:40 PM
  2. LymX
    Joined:
    Mar 19, 2009
    Posts:
    16
    Referrals:
    0
    Sythe Gold:
    10

    LymX Newcomer

    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..

    [​IMG]

    TIA
     
  3. Unread #2 - Jul 23, 2012 at 1:23 PM
  4. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

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

    Use vbCrLf
     
  5. Unread #3 - Jul 24, 2012 at 7:09 PM
  6. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    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
     
  7. Unread #4 - Jul 26, 2012 at 2:47 AM
  8. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

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

    To my knowledge VB doesn't accept them because it has its own set of characters, like vbTab, vbCr, vbLf, vbNewLine, etc.
     
  9. Unread #5 - Jul 26, 2012 at 4:38 PM
  10. mercatres
    Joined:
    Mar 2, 2008
    Posts:
    719
    Referrals:
    1
    Sythe Gold:
    0

    mercatres Apprentice
    Banned

    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.
     
  11. Unread #6 - Jul 26, 2012 at 8:57 PM
  12. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

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

    Yeah this should work if you're executing your queries right away. If you're assembling them as strings though, use vbCrLf.
     
  13. Unread #7 - Jul 27, 2012 at 12:39 AM
  14. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

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

    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.
     
  15. Unread #8 - Jul 27, 2012 at 1:31 PM
  16. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

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

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

    [​IMG]
     
  17. Unread #9 - Jul 29, 2012 at 9:04 AM
  18. Yenthe666
    Joined:
    Apr 10, 2011
    Posts:
    1,013
    Referrals:
    0
    Sythe Gold:
    0

    Yenthe666 Guru
    Banned

    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;
     
  19. Unread #10 - Jul 30, 2012 at 11:07 PM
  20. LymX
    Joined:
    Mar 19, 2009
    Posts:
    16
    Referrals:
    0
    Sythe Gold:
    10

    LymX Newcomer

    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.
     
< Split Point[] / Flood fill | Best In Carding-Credit Cards-Dumps-Cvv-Mailer-Paypal-Logins-Bank Trf etc >

Users viewing this thread
1 guest


 
 
Adblock breaks this site