Error came for Implicit conversion varchar to varbinary(max)

182
March 13, 2017, at 1:14 PM

string cs = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString; Byte[] b1; protected void Page_Load(object sender, EventArgs e) {

}
protected void btnsubmit_Click(object sender, EventArgs e)
{
    //code for pdf upload
    string filePath = fileSignature.PostedFile.FileName;
    string filename1 = Path.GetFileName(filePath);
    string ext = Path.GetExtension(filename1);
    string type = String.Empty;

//fileSignature is ID of fileupload control to upload pdf files only

    Stream fs = fileSignature.PostedFile.InputStream;
    BinaryReader br = new BinaryReader(fs);
    b1 = br.ReadBytes((Int32)fs.Length);
    byte[] b2 = b1;
    if (fileSignature.HasFile)
    {
        try
        {
            switch (ext)
            {
                case ".pdf":
                    type = "application/pdf";
                    break;
            }
            if (type != String.Empty)
            {
                fs = fileSignature.PostedFile.InputStream;
                br = new BinaryReader(fs);
                b1 = br.ReadBytes((Int32)fs.Length);
            }
            else
            {
                Response.Write("Error");
            }
        }
        catch (Exception ex)
        {
        }
    }
    //code for pic insert.........................................
    int length = filePicture.PostedFile.ContentLength;
    byte[] pic = new byte[length];
    filePicture.PostedFile.InputStream.Read(pic, 0, length);
    string QueryString = "insert into CID(FileNo,Picture,FullName,SurName,OtherName,PlaceOfBirth1,DateOfBirth1,PresentNationality,PreviousNationality,Religion,Sect,DateOfEntry,PortOfEntry,SponserNameOnEntry,WorkLocation,OfficeTelephone,Occupation1,Salary,Bank,PassportNo,PlaceOfIssue1,DateofIssue1,ExpiryDate1,ResidenceNo,PlaceOfIssue2,DatofIssue2,ExpiryDate2,Degree,University,Date1,Country,NameOfSpouse,Nationality1,PlaceOfBirth2,DateOfBirth2,Employer1,Occupation2,Children1,Children2,Children3,Children4,Children5,Children6,FatherName,Nationality2,PlaceOfBirth3,DateOfBirth3,Employer2,Occupation3,MotherName,Nationality3,PlaceOfBirth4,DateOfBirth4,Employer3,Occupation4,RelativeName1,RelativesNationality1,RelativesEmployer1,RelativeName2,RelativesNationality2,RelativesEmployer2,RelativeName3,RelativesNationality3,RelativesEmployer3,FriendName1,FriendNationality1,FriendEmployer1,FriendName2,FriendNationality2,FriendEmployer2,FriendName3,FriendNationality3,FriendEmployer3,Location,Street,LandLord,BldgNo,Floor,FlatNo,Telephone,MobileTel,Pager,POBox,PreviousOccupationInUAE1,PreviousOccupationInUAE2,PreviousOccupationInUAE3,PreviousOccupationInUAE4,VisitedCountries1,VisitedCountries2,VisitedCountries3,VisitedCountries4,VisitedCountries5,VisitedCountries6,WorkedCountries1,WorkedCountries2,WorkedCountries3,WorkedCountries4,WorkedCountries5,WorkedCountries6,CarMake,CarPlaceOfRegistration,CarPlateNo,CarPlateColor,CarDriverLicenseNo,CarPlaceOfssue,CarDateOfIssue,CarExpiryDate,HaveYouServedInMilitaryService,CarCountry,CarLevelOfService,CarRank,CarDateOfService,Name,DateOfEmployement,Section,Date2,Signature) values('" + txtFileNo.Text + "','" + pic + "','" + txtFullName.Text + "','" + txtSurName.Text + "','" + txtOtherName.Text + "','" + txtPlaceOfBirthPersonal.Text + "','" + dtpDateOfBirthPersonal.Text + "','" + txtPresentNationality.Text + "','" + txtPreviousNationality.Text + "','" + ddlReligion.SelectedValue + "','" + txtSect.Text + "','" + dtpdateofentry.Text + "','" + txtPortOfEntry.Text + "','" + txtSponserName.Text + "','" + txtWorkLocation.Text + "','" + txtOfficeTelephone.Text + "','" + txtOccupationCurrSponsor.Text + "','" + txtSalary.Text + "','" + txtBank.Text + "','" + txtPassportNo.Text + "','" + txtPlaceOfIssuePassportVisa1.Text + "','" + dtpDateOfIssuePassportVisa1.Text + "','" + txtExpiryDatePassportVisa1.Text + "','" + txtResidenceNo.Text + "','" + txtPlaceOfIssuePassportVisa2.Text + "','" + dtpDateOfIssuePassportVisa2.Text + "','" + txtExpiryDatePassportVisa2.Text + "','" + txtDegree.Text + "','" + txtUniversity.Text + "','" + dtpDateEducation.Text + "','" + ddlCountry.SelectedValue + "','" + txtNameOfSpouse.Text + "','" + txtNationalityMaritalStatus.Text + "','" + txtPlaceOfBirthMaritalStatus.Text + "','" + dtpDateOfBirthMaritalStatus.Text + "','" + txtEmployerMaritalStatus.Text + "','" + txtOccupationMaritalStatus.Text + "','" + txtChild1.Text + "','" + txtChild2.Text + "','" + txtChild3.Text + "','" + txtChild4.Text + "','" + txtChild5.Text + "','" + txtChild6.Text + "','" + txtFatherName.Text + "','" + txtNationalityParentDetails1.Text + "','" + txtPlaceOfBirthParentDetails1.Text + "','" + dtpDateOfBirthParentDetails1.Text + "','" + txtEmployerParentDetails1.Text + "','" + txtOccupationParentDetails1.Text + "','" + txtMotherName.Text + "','" + txtNationalityParentDetails2.Text + "','" + txtPlaceOfBirthParentDetails2.Text + "','" + dtpDateOfBirthParentDetails2.Text + "','" + txtEmployerParentDetails2.Text + "','" + txtOccupationParentDetails2.Text + "','" + txtNameRelatives1.Text + "','" + txtNationalityRelatives1.Text + "','" + txtEmployerRelatives1.Text + "','" + txtNameRelatives2.Text + "','" + txtNationalityRelatives2.Text + "','" + txtEmployerRelatives2.Text + "','" + txtNameRelativess3.Text + "','" + txtNationalityRelatives3.Text + "','" + txtEmployerRelatives3.Text + "','" + txtNameFriends1.Text + "','" + txtNationalityFriends1.Text + "','" + txtEmployerFriends1.Text + "','" + txtNameFriends2.Text + "','" + txtNationalityFriends2.Text + "','" + txtEmployerFriends2.Text + "','" + txtNameFriends3.Text + "','" + txtNationalityFriends3.Text + "','" + txtEmployerFriends3.Text + "','" + txtLocation.Text + "','" + txtStreet.Text + "','" + txtLandLord.Text + "','" + txtBldgNo.Text + "','" + txtFloor.Text + "','" + txtFlatNo.Text + "','" + txtTelephone.Text + "','" + txtMobileTel.Text + "','" + txtPager.Text + "','" + txtPoBox.Text + "','" + txtPreviousOccInUae1.Text + "','" + txtPreviousOccInUae2.Text + "','" + txtPreviousOccInUae3.Text + "','" + txtPreviousOccInUae4.Text + "','" + txtCountryVisited1.Text + "','" + txtCountryVisited2.Text + "','" + txtCountryVisited3.Text + "','" + txtCountryVisited4.Text + "','" + txtCountryVisited5.Text + "','" + txtCountryVisited6.Text + "','" + txtCountryWorked1.Text + "','" + txtCountryWorked2.Text + "','" + txtCountryWorked3.Text + "','" + txtCountryWorked4.Text + "','" + txtCountryWorked5.Text + "','" + txtCountryWorked6.Text + "','" + txtMake.Text + "','" + txtPlaceOfReg.Text + "','" + txtPlateNo.Text + "','" + txtPlateColor.Text + "','" + txtDriverLicenseNo.Text + "','" + txtPlaceOfIssue.Text + "','" + dtpDateOfIssueCar.Text + "','" + dtpExpiryDateCar.Text + "','" + rblServedInMilitary.SelectedValue + "','" + ddlCountryCarInfo.SelectedValue + "','" + txtLevelOfService.Text + "','" + txtRank.Text + "','" + txtDateOfService.Text + "','" + txtNameCarInfo.Text + "','" + dtpDateOfEmployement.Text + "','" + txtSection.Text + "','" + txtDateForm.Text + "','" + b2 + "')";
    SqlConnection con = new SqlConnection(cs);
    SqlCommand cmd = new SqlCommand(QueryString, con);
    con.Open();
    cmd.ExecuteNonQuery();
    Response.Write("Data Inserted");
    con.Close();
}
READ ALSO
Awk with php and mysql

Awk with php and mysql

I'm trying to use php with awkThe awk command is just to print out the password of a database so i can feed it to the php code to connect to mysql and work the rest of the code

343
What can be blocking remote login to MySQL server?

What can be blocking remote login to MySQL server?

I'm trying to set up a MySQL serverIts running on Ubuntu

192
Display dynamic column into headers with associated values [on hold]

Display dynamic column into headers with associated values [on hold]

This is not a duplicated questionI have searched the internet but couldn't find the solution

287