none
vbcrlf di C# RRS feed

  • Pertanyaan

  • Dear All


    Saya lai belajar ke C# seblumnya lama di VB6

    Di VB6

    Dim sSql as string

    Ssql=””

    Ssql=ssql &”SELECT NIK,” & vbcrlf

    Ssql=ssql &”            NAMA,” & vbcrlf

    Ssql=ssql &”            DIvisi,” & vbcrlf

    Ssql=ssql &”            GANG” & vbcrlf

    Ssql=ssql &”FROM    AAAA” & vbcrlf

    Ssql=ssql &”WHERE NIK = 1234” & vbcrlf

     

    Kalu di debug nilai ssql menjadi

     

    SELECT NIK,

              NAMA,

              DIvisi,

              GANG

    FROM AAAA

    WHERE NIK = 1234

     

     

    Kalau di C# gimana ya

     

    Thanks

    Senin, 16 November 2015 07.41

Jawaban

  • Salam kenal pak Wiyono.

    Coba anda gunakan Environment.NewLine atau "\n"

    Perhatikan kode berikut ini

    String sSql = "";
    
    sSql=sSql + "SELECT NIK," + "n\";
    
    sSql=sSql + "NAMA," + "n\";
    
    sSql=sSql + "DIvisi," + "n\";
    
    sSql=sSql + "GANG" + "n\";
    
    sSql=sSql + "FROM AAAA" + "n\";
    
    sSql=sSql + "WHERE NIK = 1234" + "n\";
    
    //C# akan menampilkan error jika anda menggunakan karakter &. Gunakan karakter + kode di atas bisa juga anda tuliskan sebagai berikut.
    
    String sSql = "";
    
    sSql=sSql + "SELECT NIK," + Environment.NewLine;
    
    sSql=sSql + "NAMA," + Environment.NewLine;
    
    sSql=sSql + "DIvisi," + Environment.NewLine;
    
    sSql=sSql + "GANG" + Environment.NewLine;
    
    sSql=sSql + "FROM AAAA" + Environment.NewLine;
    
    sSql=sSql + "WHERE NIK = 1234" + Environment.NewLine;

    Semoga membantu....



    Kamis, 19 November 2015 01.34

Semua Balasan

  • Salam kenal pak Wiyono.

    Coba anda gunakan Environment.NewLine atau "\n"

    Perhatikan kode berikut ini

    String sSql = "";
    
    sSql=sSql + "SELECT NIK," + "n\";
    
    sSql=sSql + "NAMA," + "n\";
    
    sSql=sSql + "DIvisi," + "n\";
    
    sSql=sSql + "GANG" + "n\";
    
    sSql=sSql + "FROM AAAA" + "n\";
    
    sSql=sSql + "WHERE NIK = 1234" + "n\";
    
    //C# akan menampilkan error jika anda menggunakan karakter &. Gunakan karakter + kode di atas bisa juga anda tuliskan sebagai berikut.
    
    String sSql = "";
    
    sSql=sSql + "SELECT NIK," + Environment.NewLine;
    
    sSql=sSql + "NAMA," + Environment.NewLine;
    
    sSql=sSql + "DIvisi," + Environment.NewLine;
    
    sSql=sSql + "GANG" + Environment.NewLine;
    
    sSql=sSql + "FROM AAAA" + Environment.NewLine;
    
    sSql=sSql + "WHERE NIK = 1234" + Environment.NewLine;

    Semoga membantu....



    Kamis, 19 November 2015 01.34
  • Terima kasih sekali Mas.

    Solusinya tepat sekali sesuai kebutuhan saya

    Salama kenal, sehat dan sukses selalu

    Minggu, 25 Juli 2021 02.52