Advertisement
OKIEWARDOYO

C# No.40: 1

Mar 26th, 2014
1,611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1.         private void makeConnection()
  2.         {
  3.             Console.WriteLine("\nBegin connecting...");
  4.  
  5.             connString = @"Data Source=xe;User ID=system;Password=123456;Unicode=True";
  6.  
  7.             connection = new OracleConnection(connString);
  8.  
  9.             //kalo menggunakan using block,
  10.             //maka koneksi akan otomatis closed pada akhir using block,
  11.  
  12.             try
  13.             {
  14.  
  15.                 connection.Open();
  16.  
  17.                 Console.WriteLine("Connected..");
  18.                 Console.WriteLine("ServerVersion: {0}", connection.ServerVersion);
  19.                 Console.WriteLine("State: {0}", connection.State);
  20.                 Console.WriteLine("ConnectionString: {0}", connection.ConnectionString);
  21.  
  22.                 is_connecting = true;
  23.  
  24.             }
  25.             catch (Exception ex)
  26.             {
  27.                 Console.WriteLine("Failed to Connect::" + ex.Message);
  28.  
  29.             }
  30.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement