Please Check this Error... |
| shreya verma posted at 08-May-08 06:34 |
m doing this in my Employee Profile Page and the Error is coming for that. Please check the problem out there.
Error 1: A local variable named 'EmpID' cannot be declared in this scope because it would give a different meaning to 'EmpID', which is already used in a 'parent or current' scope to denote something else
protected void Page_Load(object sender, EventArgs e)
{
string EmpID = (string)Request.QueryString["empid"];
if (!Page.IsPostBack)
{
txtEmpName.ReadOnly = true;
txtMySiteURL.ReadOnly = true;
txtRO.ReadOnly = true;
txtEMail.ReadOnly = true;
FileUpload1.Enabled = true;
}
SetValue(EmpID);
}
private void SetValue(string EmpID)
{
string EmpID = (string)Request.QueryString["empid"];
{
string constr = ConfigurationManager.ConnectionStrings["ConStr"].ToString();
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand("Usp_SetEmpById", con);
cmd.Parameters.AddWithValue( "@empid", EmpID);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
txtEmpName.Text = sdr[ "EmpName"].ToString();
txtMySiteURL.Text = sdr[ "MySiteURL"].ToString();
txtRO.Text = sdr[ "ReportingOfficer"].ToString();
txtEMail.Text = sdr[ "EMail"].ToString();
}
con.Close();
}
}
protected void btnEdit_Click(object sender, EventArgs e)
{
txtEmpName.ReadOnly = false;
txtMySiteURL.ReadOnly = false;
txtRO.ReadOnly = false;
txtEMail.ReadOnly = false;
FileUpload1.Enabled = false;
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
string EmpID = (string)Request.QueryString["empid"];
try
{
if (FileUpload1.FileName != "")
{
string strSource = FileUpload1.PostedFile.FileName;
string strDestination = AppDomain.CurrentDomain.BaseDirectory + "Uploads\\" + FileUpload1.FileName;
File.Copy(strSource, strDestination);
}
string constr = ConfigurationManager.ConnectionStrings["ConStr"].ToString();
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand("[Usp_UpdateProfile]", con);
cmd.Parameters.AddWithValue( "@name", txtEmpName.Text);
cmd.Parameters.AddWithValue( "@mysiteurl", txtMySiteURL.Text);
cmd.Parameters.AddWithValue( "@ro", txtRO.Text);
cmd.Parameters.AddWithValue( "@email", txtEMail.Text);
cmd.Parameters.AddWithValue( "@resume", FileUpload1.FileName.ToString());
cmd.Parameters.AddWithValue( "@empid", EmpID);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Directory.CreateDirectory(MapPath(".") + "\\ Uploads ");
} |
|