Click here to Skip to main content
15,891,844 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
INSERT:
C#
public bool Insert(User user)
       {
           SqlConnection con = new SqlConnection(new Connection().GetConnectionString());

           string sql = "INSERT INTO User (Email) values (@Email)";
           con.Open();
           SqlCommand cmd = new SqlCommand(sql, con);
           cmd.Parameters.AddWithValue("@Email", SqlDbType.VarChar);
           cmd.Parameters["@Email"].Value = User.email;
           //cmd.ExecuteNonQuery();

           bool isInserted = cmd.ExecuteNonQuery() > 0;
           return isInserted;

       }

UPDATE:
C#
public bool Update(User user)
       {
           SqlConnection con = new SqlConnection(new Connection().GetConnectionString());

           string sql = "UPDATE INTO User (Email) values (@Email)";
           con.Open();
           SqlCommand cmd = new SqlCommand(sql, con);
           cmd.Parameters.AddWithValue("@Email", SqlDbType.VarChar);
           cmd.Parameters["@Email"].Value = User.email;
           //cmd.ExecuteNonQuery();

           bool isUpdated = cmd.ExecuteNonQuery() > 0;
           return isUpdated;

       }
Posted
Updated 3-Mar-15 1:41am
v4

1 solution

It is always the other way round. BLL should call the DAL.
 
Share this answer
 
Comments
Shahzeb.khan90 3-Mar-15 7:26am    
yes right but what should be the BLL of the given code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900