Advertisement
Guest User

Koneksi

a guest
Aug 15th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. using MySql.Data.MySqlClient;
  8.  
  9. namespace tgs4_vb_stb
  10. {
  11.     class koneksi
  12.     {
  13.         public static string host = "localhost";
  14.  
  15.         public static string username = "root";
  16.  
  17.         public static string database = "anu_db";
  18.  
  19.         public static string password = "";
  20.  
  21.  
  22.  
  23.         public static string connect = "server=" + host + ";username=" + username + ";database=" + database + ";password=" + password;
  24.  
  25.         public static MySqlConnection konek = new MySqlConnection(connect);
  26.  
  27.        
  28.  
  29.         public static void konn()
  30.  
  31.         {
  32.  
  33.             try
  34.  
  35.             {
  36.  
  37.                 konek.Open();
  38.  
  39.                 MessageBox.Show("Selamat Anda Berhasil Koneksi ke Database");
  40.  
  41.             }
  42.  
  43.             catch
  44.  
  45.             {
  46.  
  47.                 konek.Close();
  48.  
  49.                 MessageBox.Show("Database tidak terhububg");
  50.             }
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement