Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. using Oracle.DataAccess.Client;
  2. using Oracle.DataAccess.Types;
  3. private static string GetConnectionString()
  4. {
  5. String connString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=IP_Address)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=Service_Name)));User Id=hook;Password=Password;";
  6.  
  7. return connString;
  8. }
  9.  
  10. private string ConnectingToOracle()
  11. {
  12. string connectionString = GetConnectionString();
  13. using (OracleConnection connection = new OracleConnection())
  14.  
  15. try
  16. {
  17. connection.ConnectionString = connectionString;
  18.  
  19. connection.Open();
  20.  
  21. OracleCommand command = connection.CreateCommand();
  22. string sql = " select * from sgmp.web_portal1 where account_no= '" + customerIdField.Value.ToString().Trim() + "'";
  23. command.CommandText = sql;
  24. OracleDataReader reader = command.ExecuteReader();
  25. if (reader.HasRows)
  26. {
  27. while (reader.Read())
  28.  
  29. {
  30. Session["ClientName"] = (string)reader["Customer_Name"];
  31. return (string)reader["Customer_Name"];
  32.  
  33. }
  34. }
  35. else
  36. {
  37. resp.Text = "Client ID '" + customerIdField.Value.ToString().Trim() + "' does not exist in records";
  38. return "none";
  39. }
  40.  
  41.  
  42. return "none";
  43. }
  44. catch (OracleException ex)
  45. {
  46. resp.Text = ex.Message + " reasons ..";
  47. return "mmm";
  48.  
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement