Laman

Minggu, 06 Februari 2011

membuat form login dengan database Mysql di C# ( C Sharp )

Pada tutorial kali ini akan dibuat suatu project untuk login, dimana data user dan passwordnya di simpan disuatu DBMS, dan disini DBMS yang digunakan adalah MYSQL. untuk langkah langkah pembuatannya silahkan perhatikan dibawah ini. sebelumnya siapkan terlebih dahulu project kosong, klik file new project, setelah muncul kotak dialog baru, ketik nama project pada kotak project name, klik OK. Untuk selanjutnya silahkan ikuti instruksi-instruksi dibawah ini. sebelumnya silahkan baca artikel bagaimana cara mengkoneksikan antara C# dengan DBMS mysql disini karena ini akan sangat membantu dalam memahi materi ini
langkah 1 : Tambahkan satu komponen picture box, empat label, dua button dan dua textbox, atur dan tata sedemikian rupa sehingga tampilannya seperti pada gambar dibawah.
langkah 2 : klik ganda pada button satu untuk membangkitkan event klik pada button tersebut, tambahkan code berikut ini pada event klik tersebut



langkah 3 : tambahkan function status login(string user, string password), berikut ini source lengkapnya
 

source code diatas merupakan code untuk melakukan koneksi antara C# dengan DBMS mysql, untuk cara detail bagaimana mengkonkesikan antara C# dengan mysql silahkan baca artikel disini
Langkah 4 : Buat database di mysq dengan isi filed ID,USER,PASSWORD. dan isikan data di database tersebut, nama database dan nama table dalam database adalah "formlogin"
langkah 5 : Done. program selesai dibuat


Jika langkah langkah diatas dilakukan dengan benar, maka saat program dijankan program akan menampilakan suatu form seperti pada gambar diatas, masukan password dan user sesuai dengan data yang ada didatabase, jika data password dan data user benar. akan muncul suatu form yang menunjukan bahwa login berhasil. jika data password dan data user salah, maka akan muncul pesan bahwa user dan password salah. dan jangan lupa, sewaktu menjalankan program service mysql harus berjalan. berikut preview hasil program yang sudah selesai


Gambar 1. Preview ketika program dijalankan


Gambar 2. Preview ketika program dijalankan

Untuk download full project dan lebih memahami materi ini, silahkan perhatikan video tutorial membuat form sederhana dibawah ini,
Link download ada di bagian paling akhir dari video.


pandauan download : Silahkan buka Link Download yang berada di akhir video diatas, setelah itu akan muncul halaman adf.ly, tunggu beberapa detik sampai pada pojok kanan atas muncul tulisan skip ad. klik tombol tersebut untuk full download project.

20 komentar:

  1. Ane coba modif dikit biar akses database online, kok dapet error ya?

    Host '125.161.***.***' is not allowed to connect to this MySQL server


    Apa ditolak sama database hosting ya?

    BalasHapus
  2. iya benar sekali.. program tidak mendapatkan izin akses ke DBMS online. ingat untuk akses ke DBMS ada user dan passwordnya. jika kita menggunakan DBMS MYSQL versi offline secara default user nya adalah root dan passwordnya kosong, sehingga koneksi string di program seperti ini

    string connectionSQL = "server=localhost;database=tugaspbdw;uid=root;password=;";

    perhatikan bahwasanya password="". yang artinya DBMS yang kita gunakan dalam kasus ini tidak diprotek dengan password. Jika saudara mengkoneksikan dengan versi ONLINE pastikan user dan password yang anda masukan benar.

    SEMOGA BISA MEMBANTU.......

    BalasHapus
  3. waktu saya ikutin programnya ada error kakak... pesannya Error 1 'Coba.FormCoba.trytologin(string, string)': not all code paths return a value

    BalasHapus
  4. jika pesan error seperti trytologin(string, string)': not all code paths return a value ini berarti function trytologin(string,string) belum di return values.

    ingat... pada C# function yang sudah di deklarasikan harus mempunyai nilai balik (return value) sesuai dengan type data dari function yang telah di deklarasikan sebelumnya.

    BalasHapus
  5. permisi nih, mau nnya..
    saya udah buat progaram sepintas ada mirip ny kaya ini..
    ngecek data didalaem database..
    klo data ny ga ada tapi koq hasil ny ga kluar aja yah..
    padahal saya udah pasang "messagebox" klo didalem database ngga ada datany..

    klo bingung, ini saya kasih link ke forum kaskus tempat saya bikin trit ny..
    http://www.kaskus.us/showthread.php?p=510914337#post510914337

    mohon bantuan ny, makasih.. :)

    BalasHapus
  6. untuk saudara wili.
    Progra saudara sepertinya rumayan kompleks, banyak hal dasar yang harus dipelajari mendalam, tapi sepintas dari penjelasan saudara, inti permasalahannya bukan pada koneksi dengan DBMS MYSQLnya akan tetepi pada pengolahan string inputan, saya sarankan saudara menggunakan REGEX, dengan REGEX akan lebih mudah dalam mengelola string,

    BalasHapus
  7. Boim_funkzore19 Maret 2012 20.20

    untuk yang langkah 3 di tulis di class baru atau dimna ??mohon bantuanya,,,

    BalasHapus
  8. csharp-indonesia.com20 Maret 2012 13.50

    untuk langkah ketiga source code function tersebut tetap ditulis di form pertama,
    silahkan mencoba semoga berhasil

    BalasHapus
  9. Imam Moeslim31 Mei 2012 22.50

    maksud nya FIELD ID,USER <== ?

    BalasHapus
  10. Imam Moeslim31 Mei 2012 22.50

    kenapa ga USER dan PASSWORD saja? (untuk di database)

    yang saya tanyakan. penggunaan ID nya itu untuk apa? :)

    BalasHapus
  11. Imam Moeslim2 Juni 2012 09.50

    THX banget gan... WORKS .... tp ane agak modifikasi sedikit ... :)

    BalasHapus
  12. BelajarCsharp5 Juni 2012 20.39

    Oke, terimakasih, semoga bisa membantu dan bermanfaat

    BalasHapus
  13. BelajarCsharp5 Juni 2012 20.40

    untuk ID itu merujuk ke konsep database, dimana disetiap table diharuskan mempunyai sebuat attibute yang unik atau disebut dengan Primary Key dan disini posisi ID adalah sebagai primary Key

    BalasHapus
  14. bagaimana gan kalau masukin user dan passwordnya melalui serial port?

    BalasHapus
  15. gan bagaimana kalo menggunakan session.. apakah bisa atau tdk..tq

    BalasHapus
  16. makasih mass infonya..
    info seputar bola, prediksi bola ter-update..
    berita bola TERBARU DAN TERPERCAYA hanya ada di www.bola368.net
    Kunjungi juga www.bola368.org, Anda puas Kami pun senang.!

    BalasHapus
  17. gan kalo pake excel gimana???

    BalasHapus
  18. They even feature a delicate yet adorable metal “O” icon on each side for a stylish and standout contrast. The Polarized LBD sunnies come with top-performing HDPolarized lenses which minimize glare and filter out 100% of all harmful UVA, UVB, and UVC rays, letting you conquer the sun with style. The LBD’s can be dressed up with oakley vault a gorgeous printed dress and sandals or dressed down with an easy, breezy top and cutoff shorts while lounging beachside—and you can even count on the LBD’s to keep you shielded as you sweat in style while enjoying an outdoor run. No matter how what you’ve got planned for summer, one thing lies for oakley womens sunglasses certain, you can rely on Oakley’s LBD’s to be your summer staple to feel stylish and sexy while on the move.
    That’s creative marketing and publicity at its finest.Greene poses in a variety of photos for the campaign. She’s seen performing her favorite workouts. In one photo, she performs some planks. In another photo, fake oakleys cheap shipping she looks like she’s getting ready for a run.Greene also poses in various workout gear. She can be seen everything from an aqua blue camisole and purple leggings to a purple sports. She’s not without her Oakley sunglasses either.Greene said in a recent statement that fitness is an important part of her life. She discount oakley sunglasses admits that she loves to feel strong. Greene is glad to be a part of Oakley’s campaign because she wants to encourage others to life a healthy and active lifestyle.Ashley Green revealed to People that she tries to stay active by walking her dogs or taking hikes every day. It looks like this “Twilight” oakley star will bring some fitness inspiration to her young fans.
    Melbourne, FL (December 13, 2014) ? This is the time of the year when companies have their employees select their health, dental and vision benefits for the up and coming new year. All the companies I have worked for and the school district sunglass hut I now work for have a vision plan. Visions plans, depending what level the employee chooses will give the employee one examination every two years and a pair of free glasses. This year I chose the high end plan that reduced the plan from every two years to every year. I am really excited oakley outlet about the yearly plan because it allows me and my wife more options when selecting frames and lenses.Before I started wearing Rx sunglasses, I was wearing Guideline Eclipse sunglasses. I like them so much that I decided to give the Guideline RX a chance and I have not been disappointed.Early this year, both my http://www.warbyparkersunglasshut.com wife and I started wearing Guideline Rx sunglasses and we both just love the overall quality of these sunglasses

    BalasHapus
  19. “It says, ‘I’m not Ray-Ban, I’m Blakened,” says Hinton.24DP, an award winning Greenwich Village-based production company ray ban sunglasses sale and creative group, formally announced its expansion into a full service advertising agency today. The firm’s new addition to its business model will provide advertisers with a welcomed alternative to large and costly agencies that are synonymous with Madison Avenue.In a press statement, CEO Brian Cristiano, a sunglass hut 2008 New York Emmy? award winner [Advanced Media: Commercial] acknowledges “it is a fact that large advertising agencies have massive overhead and that their clients pay for it directly.” These high operational costs are directly correlated to their reliance upon third party vendors for production and creative ## services. As 24DP will now function as an all-in-one advertising, creative and production house, clients will doubtlessly benefit from its streamlined and very cost effective services; all campaign elements – from conceptualization to execution, and everything in between – will be handled in-house, saving businesses time ray ban aviators and money, while maximizing ROI and leveragability.
    Take a look at some of the pictures from my Coachella adventures, including the obligatory In-n-Out stop, the bags I brought and the infamous Coachella Ferris Wheel (if you ever get a chance to ride, DO IT!). Having the Twilight ray ban glasses cast sport your product is certainly no hindrance to forward progress in marketing.At least, that's been the case with a few of those companies whose goods have been featured in the Twilight series or upon its cast.With Volvo, for instance, we've seen that the vehicle models appearing discount ray ban sunglasses in Twilight and The Twilight Saga: New Moon enjoyed subsequent sales boosts which the company attributed to inclusion in the picture.The same, it seems, is true for Ray-Bans.According to a recent press release, Ray-Ban is reporting record sales for this year, and they have the Twilight films ray ban sunglasses and cast to thank for it."Ray-Ban sunglasses have long been a favorite of celebrities, and are seeing a resurgence in the younger generation, most recently amongst the stars of the ‘Twilight’ films, who have been seen wearing Ray-Ban Wayfarers in the movies and in real life."
    While ray ban clubmaster classic black Wayfarers will never go out of style, Ray Ban also currently offers a contemporary color palette allowing you to display your own style and personality. And you can even go crazy and express yourself ray ban clubmasters with the latest addition to Ray-Ban Wayfarer sunglasses in the limited edition Rare Prints. These funky prints are inspired by themes that represent the essence of Ray-Ban’s history and style. While these Ray Bans are perfect for a day at the beach, they are yet chic enough to be paired with the most cosmopolitan of ensembles.

    BalasHapus