i hav got a oledb error each time while inserting or updating but select statements are perfectly working pls ny1 can solv my probl..
CODE
Imports System.Data.OleDb
Public Class newlogin
Public Sub clearfields()
txtname.Text = ""
txtrole.Text = ""
txtgender.Text = ""
txtedu.Text = ""
txtemail.Text = ""
txtuser.Text = ""
txtpass.Text = ""
txtcourse.Text = ""
End Sub
Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Database.mdb")
Dim errora As Integer = 0
Dim query As String
If con.State = ConnectionState.Open Then con.Close()
Try
query = "insert into login(fullname,role,gender,education,email,username,password,course) values( '" & txtname.Text & "' , '" & txtrole.Text & "' , '" & txtgender.Text & "' , '" & txtedu.Text & "' , '" & txtemail.Text & "' , '" & txtuser.Text & "' , '" & txtpass.Text & "' , '" & txtcourse.Text & "' )"
Dim cmda As New OleDbCommand(query, con)
con.Open()
cmda.ExecuteNonQuery()
con.Close()
Catch exo As OleDbException
MsgBox(exo.Message, MsgBoxStyle.Critical, "Oledb error")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "General error")
errora = 1
End Try
If Not errora = 1 Then
MsgBox("Contact Added")
clearfields()
End If
con.Close()
End Sub
Private Sub reset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
clearfields()
End Sub
End Class