protected void BtnSave_Click(object sender, EventArgs e) { lblUserName.Text = Session["LoginName"].ToString(); { string connetionString = "Data Source=ANONYMOUS-PC\\SQLEXPRESS;Initial Catalog=EmployeeDB;User ID=sa;Password=Mo7am00d"; using (SqlConnection con = new SqlConnection(connetionString)) { using (SqlCommand cmd = new SqlCommand("SP_PROJMASTER", con)) { objLogin.Projnum = TxtProjectNum.Text; DataTable dtTrans = new DataTable(); dtTrans = objLogin.ValidateProj(); if (dtTrans.Rows.Count != 0) { // lblMessage.Text = "Transaction Number Already Exists!"; //cmd.CommandType = CommandType.StoredProcedure; //Response.Redirect("RptLocHours.aspx"); //Page.ClientScript.RegisterStartupScript(this.GetType(),"Scripts","<script>alert('Transaction Number Already Exists!');</script>"); Response.Redirect("ErrorProj.aspx"); } else { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Mode", SqlDbType.VarChar).Value = "Insert"; cmd.Parameters.Add("@LOCID", SqlDbType.VarChar).Value = ddlLocation.SelectedValue.ToString(); cmd.Parameters.Add("@PROJNO", SqlDbType.VarChar).Value = TxtProjectNum.Text.ToString(); cmd.Parameters.Add("@PROJDESC", SqlDbType.VarChar).Value = TxtProjctName.Text.ToString(); cmd.Parameters.Add("@EPCCOMP", SqlDbType.VarChar).Value = TxtEpcComp.Text.ToString(); cmd.Parameters.Add("@USERNAME", SqlDbType.VarChar).Value = lblUserName.Text.ToString(); con.Open(); cmd.ExecuteNonQuery(); } } } } BindGridview(); }