krish sin

krish sin

  • NA
  • 17
  • 1.2k

asp.net c#.no mapping exists whether my code is correct

Dec 21 2016 12:36 AM

asp.net c#.No mapping exists from object type System.Web.UI.WebControls.FileUpload to a known managed provider native type

this the error..
 
how to debug
 
this is the code  :
 
protected void Page_Load(object sender, EventArgs e) {   } protected void btn_insrt_Click(object sender, EventArgs e) { try { SqlConnection con = new SqlConnection("Data Source=SYSTEM-6-PC;Initial Catalog=HRMS;Integrated Security=True");         con.Open(); FileUpload img = (FileUpload)imgUpload; Byte[] imgByte = null; if (img.HasFile && img.PostedFile != null) { //To create a PostedFile HttpPostedFile File = imgUpload.PostedFile; //Create byte Array with file len             imgByte = new Byte[File.ContentLength]; //force the control to load data in array File.InputStream.Read(imgByte, 0, File.ContentLength); } SqlCommand cmd = new SqlCommand("INSERT INTO HR_information([HRName],[HRCode],[Designation],[Department],[Qulification],[DateOfBirth]" + ",[Phone],[Mobile],[MaritalStatus] ,[Email] ,[ZipCode],[Address] ,[Street],[City] ,[State] ,[Country],[Photo],[PassportNo]) VALUES (@HRName,@HRCode,@Designation,@Department,@Qulification,@DateOfBirth" + ", @Phone,@Mobile,@MaritalStatus,@Email @ZipCode,@Address,@Street,@City,@State,@Country,,@eimg,@ PassportNo)", con);          cmd.Parameters.AddWithValue("@HRName", txt_name.Text);         cmd.Parameters.AddWithValue("@HRCode", txt_code.Text);         cmd.Parameters.AddWithValue("@Designation", drpdwn_desig.SelectedItem.ToString());         cmd.Parameters.AddWithValue("@Department", drpdwn_dept.SelectedItem.ToString());         cmd.Parameters.AddWithValue("@Qulification", txt_qual.Text);         cmd.Parameters.AddWithValue("@DateOfBirth", txt_dob.Text);         cmd.Parameters.AddWithValue(" @Phone", txt_phn.Text);         cmd.Parameters.AddWithValue("@Mobile", txt_mob.Text);         cmd.Parameters.AddWithValue("@MaritalStatus", Dropdownmatrialstatus.SelectedItem.ToString());         cmd.Parameters.AddWithValue("@Email", txt_email.Text);         cmd.Parameters.AddWithValue("@ZipCode", txt_zip.Text);         cmd.Parameters.AddWithValue("@Address", txt_addr.Text);         cmd.Parameters.AddWithValue("@Street", txt_str.Text);         cmd.Parameters.AddWithValue("@City", txt_cty.Text);         cmd.Parameters.AddWithValue("@State", drpdwn_state.SelectedItem.ToString());         cmd.Parameters.AddWithValue("@Country", txt_ctry.Text);         cmd.Parameters.AddWithValue(",@eimg", img);         cmd.Parameters.AddWithValue("@ PassportNo", txt_passportno.Text);          cmd.ExecuteNonQuery(); } catch (Exception) { }   }

}

 

Answers (2)