reetesh kiran

reetesh kiran

  • NA
  • 5
  • 663

getting error when inserting data into data base

May 3 2018 2:10 AM
when click on submit button getting error as
 
" Implicit conversion from data type varchar to varbinary is not allowed. Use the CONVERT function to run this query."
 
my c# code :-
  1. protected void Button1_Click(object sender, EventArgs e)  
  2. {  
  3. if (RadioButton1.Checked)  
  4. {  
  5. Gender = "Male";  
  6. }  
  7. else if (RadioButton2.Checked)  
  8. {  
  9. Gender = "Female";  
  10. }  
  11. else if (RadioButton3.Checked)  
  12. {  
  13. Gender = "Other";  
  14. }  
  15. if (RadioButton4.Checked)  
  16. {  
  17. Relationship = "Father";  
  18. }  
  19. else if (RadioButton5.Checked)  
  20. {  
  21. Relationship = "Mother";  
  22. }  
  23. a = Class1.GetRandomPassword(5).ToString();  
  24. FileUpload1.SaveAs(Request.PhysicalApplicationPath + "./images/registration/" + a + FileUpload1.FileName.ToString());  
  25. a1 = "images/registration" + a + FileUpload1.FileName.ToString();  
  26. b = Class1.GetRandomPassword(5).ToString();  
  27. FileUpload2.SaveAs(Request.PhysicalApplicationPath + "./images/registration/" + b + FileUpload2.FileName.ToString());  
  28. b2 = "images/registration" + b + FileUpload2.FileName.ToString();  
  29. c = Class1.GetRandomPassword(5).ToString();  
  30. FileUpload3.SaveAs(Request.PhysicalApplicationPath + "./images/registration/" + c + FileUpload3.FileName.ToString());  
  31. c3 = "images/registration" + c + FileUpload3.FileName.ToString();  
  32. d = Class1.GetRandomPassword(5).ToString();  
  33. FileUpload4.SaveAs(Request.PhysicalApplicationPath + "./images/registration/" + d + FileUpload4.FileName.ToString());  
  34. d4 = "images/registration" + d + FileUpload4.FileName.ToString();  
  35. g = Class1.GetRandomPassword(5).ToString();  
  36. FileUpload5.SaveAs(Request.PhysicalApplicationPath + "./images/registration/" + g + FileUpload5.FileName.ToString());  
  37. g5 = "images/registration" + g + FileUpload5.FileName.ToString();  
  38. f = Class1.GetRandomPassword(5).ToString();  
  39. FileUpload6.SaveAs(Request.PhysicalApplicationPath + "./images/registration/" + f + FileUpload6.FileName.ToString());  
  40. f6 = "images/registration" + f + FileUpload6.FileName.ToString();  
  41. con.Open();  
  42. SqlCommand cmd = con.CreateCommand();  
  43. cmd.CommandType = CommandType.Text;  
  44. cmd.CommandText = "insert into registration values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + Gender + "','" + dob.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox12.Text + "','" + TextBox13.Text + "','" + TextBox14.Text + "','" + TextBox15.Text + "','" + TextBox16.Text + "','" + TextBox17.Text + "','" + TextBox18.Text + "','" + TextBox19.Text + "','" + TextBox20.Text + "','" + TextBox21.Text + "','" + TextBox22.Text + "','" + Relationship + "','" + TextBox23.Text + "','" + TextBox24.Text + "','" + TextBox25.Text + "','" + TextBox26.Text + "','" + a1.ToString() + "','" + b2.ToString() + "','" + c3.ToString() + "','" + d4.ToString() + "','" + g5.ToString() + "','" + f6.ToString() + "')";  
  45. cmd.ExecuteNonQuery();  
  46. con.Close();  
  47. } 

Answers (5)