none
Conversion from string "" to type 'Integer' is not valid

    Question

  • i TRY TO RUN MY PROGRAMME BUT IT GIVE ME THIS ERROR"

    Conversion from string "" to type 'Integer' is not valid"

    I AM TRYING TO INSERT A DATA INTO MY sql

     Dim DeptObject As New EmployeeData()
            DeptObject.insertIntoData(SurnameTextBox.Text, Maiden_Name_if_any_TextBox.Text, Home_TownTextBox.Text, Phone_NumberTextBox.Text.ToString, GradeTextBox.Text, PicturePictureBox.Image.ToString, NationalityTextBox.Text, AgeTextBox.Text.ToString, AddressTextBox.Text, Residential_AddressTextBox.Text, Date_of_BirthDateTimePicker.ToString.ToString, _Identification_ModeComboBox.Text, _1_School_AttendedTextBox.Text, _1_PeriodTextBox.Text, _1_QualificationTextBox.Text, _2_School_AttendedTextBox1.Text, _2_PeriodTextBox.Text, _2_QualificationTextBox.Text, _3_School_AttendedTextBox.Text, _3_PeriodTextBox.Text, _3_QualificationTextBox.Text, _4_School_AttendedTextBox.Text, _4_PeriodTextBox.Text, _4_QualificationTextBox.Text, _1_Other_Places_WorkedTextBox.Text, _1_Period_WorkedTextBox.Text, _1_DesignationTextBox.Text, _2_Other_Places_WorkedTextBox.Text, _2_Period_WorkedTextBox.Text, _2_DesignationTextBox.Text, _3_Other_Places_WorkedTextBox.Text, _3_Period_WorkedTextBox.Text, _3_DesignationTextBox.Text, Next_of_KinTextBox.Text, Address_of_Next_of_KinTextBox.Text, Home_Town1TextBox.Text, Relation_to_Next_of_KinTextBox.Text, Name_of_SpouseTextBox.Text, Spouse_AgeTextBox.Text, Spouse_NationalityTextBox.Text, Brief_Information_of_PrentsTextBox.Text, Child_NameTextBox.Text, _1_Date_of_BirthDateTimePicker.ToString, _1_SexComboBox.Text, _2__Child_NameTextBox.Text, _2_Date_of_BirthDateTimePicker.ToString, _2_SexComboBox.Text, _3__Child_NameTextBox.Text, _3_Date_of_BirthDateTimePicker.ToString, _3_SexComboBox.Text, _4__Child_NameTextBox.Text, _4_Date_of_BirthDateTimePicker.ToString, _4_SexComboBox.Text, _5__Child_NameTextBox.Text, _5_Date_of_BirthDateTimePicker.ToString, _5_SexComboBox.Text, Thumb_PrintPictureBox.Image.ToString, First_NameTextBox.Text)

    Wednesday, July 06, 2011 12:42 AM

Answers

  • Most likely application is trying to submit some string value(s) into integer type column. It could be an empty string (keep in mind that empty string is not NULL value) or just a string value that cannot be converted into numeric one. Usually you would receive this error if you concatenate values into dynamic SQL statement without checking for proper values. I would recommend checking SQL statement for submitted values to resolve this issue.


    Val Mazur (MVP)

    http://www.xporttools.net

    Wednesday, July 06, 2011 10:28 AM
    Moderator
  • Hi Bed,

    Welcome to the Forum.  

    It seems the application is try to convert to the empty string to integer type and it is invalid in VB.net.  I suggest you could:
    1、 Verify the string formatter before you convert it to integer type, e.g. String.IsNullOrEmpty(stringValue);
    2、 The empty string default is 0 in MSSQL, you can  delay the conversation in your database;
    3、 We can verify the formatter before submit.

    I hope that would be help you.

     

     Thanks for all the participators.



    David Peng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.




    Thursday, July 07, 2011 2:50 AM
    Moderator

All replies

  • Most likely application is trying to submit some string value(s) into integer type column. It could be an empty string (keep in mind that empty string is not NULL value) or just a string value that cannot be converted into numeric one. Usually you would receive this error if you concatenate values into dynamic SQL statement without checking for proper values. I would recommend checking SQL statement for submitted values to resolve this issue.


    Val Mazur (MVP)

    http://www.xporttools.net

    Wednesday, July 06, 2011 10:28 AM
    Moderator
  • Hi Bed,

    Welcome to the Forum.  

    It seems the application is try to convert to the empty string to integer type and it is invalid in VB.net.  I suggest you could:
    1、 Verify the string formatter before you convert it to integer type, e.g. String.IsNullOrEmpty(stringValue);
    2、 The empty string default is 0 in MSSQL, you can  delay the conversation in your database;
    3、 We can verify the formatter before submit.

    I hope that would be help you.

     

     Thanks for all the participators.



    David Peng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.




    Thursday, July 07, 2011 2:50 AM
    Moderator
  • Hi Bed,

     

    What's the status on the issue? Is there any problem please let me know.


    If it's helpful for you, Please vote or mark. Thank you!

    David Peng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, July 15, 2011 1:21 AM
    Moderator