Use following code structure to add values in access database
Public con As New OleDb.OleDbConnection
Public objda As New OleDb.OleDbDataAdapter
If con.State = ConnectionState.Open Then
con.Close()
End If
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\DatabaseName.mdb"
Try
con.Open()
Catch ex As Exception
MessageBox.Show("Please Contact Application Developer", "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End
End Try
objda.SelectCommand = New OleDbCommand
objda.SelectCommand.CommandText = "Insert into TableName(Field1, Field2) values(@Field1, @Field2)"
objda.SelectCommand.Parameters.AddWithValue("@Field1", Textbox1.Text)
objda.SelectCommand.Parameters.AddWithValue("@Field2",Textbox2.Text)
Try
objda.SelectCommand.ExecuteNonQuery()
Catch ex As OleDb.OleDbException
MessageBox.Show(ex.Message)
End Try