pl help

i m getting insert into error

Private Sub Addbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Addbtn.Click
        Dim mycmd1 As OleDbCommand
        Dim sqlq1 As String
        Try

       
            If Addbtn.Text = "Add" Then
                Idtxt.Text = Me.max + 1
                clear()
                Addbtn.Text = "Save"
                
            Else

                sqlq1 = "Insert into Member values(" & Idtxt.Text & ", '" & Nametxt.Text & "', '" & DateTimePicker1.Value & "', '" & gendercb.Text & "', '" & Classcb.Text & "','" & WingCb.Text & "', '" & FloorCb.Text & "', '" & RoomCb.Text & "', '" & occtxt.Text & "')"
                mycmd1 = New OleDbCommand(sqlq1, con)
                mycmd1.ExecuteNonQuery()
                MsgBox("added succesfuly")
                RecordRefresh()  // refresh the record
                
                Addbtn.Text = "Add"

where idtxt is number and remaining are text
and max is total row count

pl...........
help

Recommended Answers

All 2 Replies

You would have to specify the fields that you're inserting into like:

Insert into Member(?,?,?,?,?,?,?,?,?) values(" & Idtxt.Text & ", '" & Nametxt.Text & "', '" & DateTimePicker1.Value & "', '" & gendercb.Text & "', '" & Classcb.Text & "','" & WingCb.Text & "', '" & FloorCb.Text & "', '" & RoomCb.Text & "', '" & occtxt.Text & "')


This is because i don't really know your member_table values.....!!!

thanks i solved this error but new error is coming data type mismatch what should i do for this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.