-1

i'm having a problem i insert a value it will show a error:
incorrect integer value: "for column 'student_no' at row 1

this is the code

    Try

            MySqlConnection.Open()
            Dim query As String
            query = " insert into mcs.payment(student_no, mode, registration_fee, miscellaneous_fee, tuition_fee, ptca_fee, computer_fee, user) values ('" & lblstudentno.Text & "', '" & ComboBox1.Text & "','" & txtregfee.Text & "', '" & txtmisfee.Text & "', '" & txttuitionfee.Text & "', '" & txtptcafee.Text & "', '" & txtcompfee.Text & "', '" & lbluser.Text & "') "
            Dim Command As New MySqlCommand(query, MySqlConnection)
            READER = Command.ExecuteReader

            MessageBox.Show("OK")
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            MySqlConnection.Dispose()

        End Try

can you help me???

Kaye Santos
  • 45
  • 1
  • 2
  • 7
  • 2
    Use [Parameterized Queries](http://stackoverflow.com/questions/542510/how-do-i-create-a-parameterized-sql-query-why-should-i) – OneFineDay Oct 14 '14 at 01:44

1 Answers1

0

The student_no is an integer column but you try to insert a string value in it.

"'" & lblstudentno.Text & "'"

You just need to remove those single quotes and it will insert an integer... of course I assuming that the lblstudentno.Text is a number (other column may also raise errors).

HOWEVER You should NEVER build a query like this because it will leave the door open for SQL injection. Parameterized queries is the right way to handle sql queries.

The_Black_Smurf
  • 5,178
  • 14
  • 52
  • 78