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_TRANSACTIONS", con)) { objLogin.Transnum = txtTransNum.Text; DataTable dtTrans = new DataTable(); dtTrans = objLogin.ValidateTrans(); if (dtTrans.Rows.Count != 0) { Response.Redirect("ErrorTrans.aspx"); } else { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Mode", SqlDbType.NVarChar).Value = "Insert"; cmd.Parameters.Add("@TRANSNUM", SqlDbType.NVarChar).Value = txtTransNum.Text.ToString(); cmd.Parameters.Add("@WORKDATE", SqlDbType.NVarChar).Value = lblDatepicker.Text.ToString(); cmd.Parameters.Add("@LOCDESC", SqlDbType.NVarChar).Value = ddlLocation.SelectedItem.Text; cmd.Parameters.Add("@PROJDESC", SqlDbType.NVarChar).Value = ddlProjects.SelectedItem.Text; cmd.Parameters.Add("@DELDESC", SqlDbType.NVarChar).Value = ddlDeliverables.SelectedItem.Text; cmd.Parameters.Add("@WORKHRS", SqlDbType.NVarChar).Value = txtHours.Text.ToString(); cmd.Parameters.Add("@USERNAME", SqlDbType.NVarChar).Value = lblUserName.Text.ToString(); } con.Open(); cmd.ExecuteNonQuery(); } // BindGridview(); } //else //{ // DataRow drLogin; // drLogin = dtUser.Rows[0]; // Session["LoginName"] = drLogin["LoginName"].ToString(); // Session["Rights"] = drLogin["Rights"].ToString(); // Response.Redirect("AddNewProject.aspx"); //} } }