Guest User

Untitled

a guest
Jan 20th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. using System;
  2. using Oracle.ManagedDataAccess.Client;
  3.  
  4. namespace ConsoleApp1
  5. {
  6. class Program
  7. {
  8. private static readonly string connectinString = "Data Source=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.99.100)(PORT = 1521)))(CONNECT_DATA = (SID = xe)));Persist Security Info=True;User ID=Teste;Password=123456;Pooling=True;Connection Timeout=60;";
  9. static void Main(string[] args)
  10. {
  11. Console.WriteLine("Hello Oracle!");
  12.  
  13. using (var conn = new OracleConnection(connectinString))
  14. {
  15. using (var cmd = conn.CreateCommand())
  16. {
  17. conn.Open();
  18.  
  19. cmd.CommandText = "select * from pessoa";
  20.  
  21. var reader = cmd.ExecuteReader();
  22.  
  23. while (reader.Read())
  24. {
  25. Console.WriteLine("===========================");
  26. Console.WriteLine($"Id:{reader["Id"]}");
  27. Console.WriteLine($"Nome: {reader["Nome"]}");
  28. }
  29.  
  30. Console.WriteLine("===========================");
  31.  
  32. reader.Dispose();
  33. }
  34. }
  35.  
  36. Console.ReadKey();
  37. }
  38. }
  39. }
Add Comment
Please, Sign In to add comment