Adblock breaks this site

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.

  1. LymX

    LymX Newcomer

    Joined:
    Mar 19, 2009
    Posts:
    16
    Referrals:
    0
    Sythe Gold:
    10
    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
     
  2. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

    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
    How do i use new line or tab in sql DB with visual basic 2010

    Use vbCrLf
     
  3. Swan

    Swan When They Cry...
    Retired Global Moderator

    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner
    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
     
  4. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

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

    mercatres Apprentice
    Banned

    Joined:
    Mar 2, 2008
    Posts:
    719
    Referrals:
    1
    Sythe Gold:
    0
    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.
     
  6. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

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

    Swan When They Cry...
    Retired Global Moderator

    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner
    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.
     
  8. Blupig

    Blupig BEEF TOILET
    $5 USD Donor

    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
    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]
     
  9. Yenthe666

    Yenthe666 Guru
    Banned

    Joined:
    Apr 10, 2011
    Posts:
    1,013
    Referrals:
    0
    Sythe Gold:
    0
    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;
     
  10. LymX

    LymX Newcomer

    Joined:
    Mar 19, 2009
    Posts:
    16
    Referrals:
    0
    Sythe Gold:
    10
    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 >


 
 
Adblock breaks this site