Advertisement
Guest User

BookingDA.cs

a guest
Apr 17th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Configuration;
  6. using System.Data.SqlClient;
  7. using System.Data.OleDb;
  8.  
  9.  
  10.  
  11. namespace PersistentLayer
  12. {
  13.     public class BookingDA
  14.     {
  15.         string connstringOLEDB = ConfigurationManager.ConnectionStrings["ConnectionStringOLDEDB"].ToString();
  16.        
  17.        
  18.         #region Client Booking Related Commands
  19.  
  20.         public void createClient(string cFirstName, string cLastName, string cEmail, string cMobile, string cAddress)
  21.         {
  22.             int clientID =0;
  23.             OleDbConnection con = new OleDbConnection(connstringOLEDB);
  24.             con.Open();
  25.  
  26.             try
  27.             {
  28.                 //Get the Max IDNO so we can increment by one to create a new client
  29.                 string sqlMaxQuery = "Select MAX (clientID) FROM Client";
  30.                 OleDbCommand cmd = new OleDbCommand(sqlMaxQuery, con);
  31.                 clientID = (int)cmd.ExecuteScalar() + 1;
  32.  
  33.                 //Insert a new client
  34.                 string sqlInsertNewClient = "Insert into Client (ClientID, cFirstName, cLastName, cEmail, cMobile, cAddress) VALUES('" + clientID + "', '" + cFirstName + "', '" + cLastName + "', '" + cEmail + "', '" + cMobile + "', '" + cAddress + "' );";
  35.                 OleDbCommand command = new OleDbCommand(sqlInsertNewClient, con);
  36.                 command.ExecuteNonQuery();
  37.                 con.Close();
  38.  
  39.  
  40.  
  41.             }
  42.             catch
  43.             {
  44.                 throw new Exception();
  45.             }
  46.             finally
  47.             {
  48.                 if (con != null)
  49.                 {
  50.                     con.Close();
  51.                 }
  52.             }
  53.         }
  54.  
  55.    
  56.         #endregion
  57.  
  58.         #region Booking Creation Related Commadns
  59.        
  60.         #endregion
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement