Q: Я сумасшедший?У меня есть событие.Имя скопировано / вставлено, поэтому я знаю, что это не опечатка.Что мне здесь не хватает? (Не беспокойтесь о параметрах, пожалуйста, это для обучения, и мне сказали, чтобы не использовать их сейчас)1007 *
protected void BtnEpl_Click(object sender, EventArgs e)
{
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
string EplQuery = "INSERT INTO EPL (Entity, Employees, CA, MI, NY, NJ, Primex, EplLim, EplSir, Premium, Wage, Sublim) VALUES ('" + TbEplEntity + "', '" + TbEplTotalEmpl + "', '" + TbEplCalEmpl + "', '" + TbEplMichEmpl + "', '" + TbEplNyEmpl + "', '" + TbEplNjEmpl + "', '" + TbEplPrimEx + "', '" + TbEplLim + "', '" + TbEplEplSir + "', '" + TbEplPrem + "', '" + TbEplWage + "', '" + TbEplInvestCost + "')";
string EplIdQuery = "SELECT SCOPE_IDENTITY() AS LastInsertedInstanceId";
using (SqlConnection EplConn = new SqlConnection(connectionString))
{
EplConn.Open();
SqlCommand EplCmd = new SqlCommand(EplQuery, EplConn);
SqlCommand EplIdCmd = new SqlCommand(EplIdQuery, EplConn);
using (EplCmd)
using (EplIdCmd)
{
EplCmd.ExecuteNonQuery();
SqlDataReader EplDr = EplIdCmd.ExecuteReader();
EplDr.Read();
int lastInsertedInstanceId = Convert.ToInt32(EplDr[0]);
}
string x = Request.QueryString["InstanceId"];
string EplShowQuery = "SELECT Entity, Employees, CA, MI, NY, NJ, Primex, EplLim, EplSir, Premium, Wage, Sublim FROM EPL WHERE InstanceId =" + x;
using (SqlCommand EplShowCmd = new SqlCommand(EplShowQuery, EplConn))
{
SqlDataReader EplDr = EplShowCmd.ExecuteReader();
EplDr.Read();
LblEplShowEntity.Text = EplDr.GetString(0);
LblEplShowTotalEmpl.Text = EplDr.GetInt32(1).ToString();
LblEplShowCalEmpl.Text = EplDr.GetInt32(2).ToString();
LblEplShowMichEmpl.Text = EplDr.GetInt32(3).ToString();
LblEplShowNyEmpl.Text = EplDr.GetInt32(4).ToString();
LblEplShowNjEmpl.Text = EplDr.GetInt32(5).ToString();
LblEplShowPrimEx.Text = EplDr.GetInt32(6).ToString();
LblEplShowLim.Text = EplDr.GetInt32(7).ToString();
LblEplShowSir.Text = EplDr.GetInt32(8).ToString();
LblEplShowPrem.Text = EplDr.GetInt32(9).ToString();
LblEplShowWage.Text = EplDr.GetInt32(10).ToString();
LblEplShowInvestCost.Text = EplDr.GetInt32(11).ToString();
}
}
UdpEPL.Visible = false;
UdpEplShow.Visible = true;
}
}