Exemplo n.º 1
0
 public string GetNameCustomer(string cardNo)
 {
     try
     {
         string name  = "TECHCOMBANK ACCOUNT";
         string query = "SELECT Customer.Name FROM Account INNER JOIN Customer on Account.CustID = Customer.CustomerID INNER JOIN Card on Account.AccountID = Card.AccountID WHERE CardNo = @cardNo";
         dbContext.OpenConnection();
         SqlCommand cmd = new SqlCommand(query, dbContext.Connect);
         cmd.Parameters.AddWithValue("cardNo", cardNo);
         SqlDataReader dr = cmd.ExecuteReader();
         while (dr.Read())
         {
             name = dr["Name"].ToString();
         }
         dbContext.CloseConnection();
         return(name);
     }
     catch
     {
         if (dbContext.CHECK_OPEN)
         {
             dbContext.CloseConnection();
         }
         return("");
     }
 }