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 ");

}


Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  Please Check this Error... - shreya verma  08-May-08 06:34 6:34:11 AM
      correction.. - santhosh kapa  08-May-08 06:39 6:39:14 AM
          See Dear... - shreya verma  08-May-08 06:43 6:43:32 AM
              debug and check... - Vasanthakumar D  08-May-08 06:50 6:50:12 AM
                  No change.. - shreya verma  08-May-08 06:55 6:55:22 AM
                      Re : - Sunil Lakshkar  08-May-08 07:11 7:11:48 AM
                          Thanks - shreya verma  08-May-08 07:33 7:33:11 AM
              check empid from querystring.. - santhosh kapa  08-May-08 06:54 6:54:35 AM
                  Hiii - shreya verma  08-May-08 06:56 6:56:47 AM
              See This - Sanjay Verma  08-May-08 07:14 7:14:49 AM
                  Syntax Error - shreya verma  08-May-08 07:23 7:23:57 AM
                      Check your SP - Sanjay Verma  09-May-08 02:03 2:03:29 AM
      Re:Re-Declaration - Sunil Lakshkar  08-May-08 06:43 6:43:42 AM
          see.... - shreya verma  08-May-08 06:49 6:49:03 AM
      RE: - Sunil Lakshkar  08-May-08 06:59 6:59:05 AM
          no change - shreya verma  08-May-08 07:03 7:03:03 AM
View Posts