Monday, February 2, 2009

Visual Basic 2008 using OLEDB to Connect MS Access Database

I have made a simple program from Visual Basic 2008 using OLEDB to connect MS Access databases.

In this program, the user can add, edit, search and view records using a listview.

5 comments:

Anonymous said...

Good day, thank you for your code its very helpful but after i checked theres a little problem.

1. if you edit & save a new records it will go successfully but try to add new record it will just append the previous edited record.
2.What is the use of ADDMODE

thanks

Mario Malferrari said...

for #1, ill just recheck it.

for #2, addmode is not being used.

thanks for the reply...

Unknown said...

Hey there people form OptionTech!
I used your database example to work out some sort of application for myself. But I have a little problem with editing a database entry. Some how it doesn't accept the If IsExists() = False Then

It just makes a new entry with the updated information. This is my code:

Sub SaveEntry(ByVal BM_Naam As String, ByVal BM_Leeftijd As String, ByVal BM_Lengte As String, ByVal BM_Gewicht As String)
Try
If IsExists() = False Then
MessageBox.Show("New entry!?")

strSQL = "INSERT INTO tblBoxerMaster(BM_Naam,BM_Leeftijd,BM_Lengte,BM_Gewicht) VALUES('" _
& BM_Naam.ToString & "' ,'" _
& BM_Leeftijd.ToString & "' ,'" _
& BM_Lengte.ToString & "' ,'" _
& BM_Gewicht.ToString & " ,')"
Else

MessageBox.Show("Update!?")
strSQL = "UPDATE tblBoxerMaster SET BM_Leeftijd = '" & BM_Leeftijd.ToString & "'," _
& "BM_Lengte = '" & BM_Lengte.ToString & "'," _
& "BM_Gewicht = '" & BM_Gewicht.ToString & "'," _
& "BM_Naam = '" & BM_Naam.ToString & "'," _
& "WHERE BM_ID = " & Ctrl & ""
End If

DO you have any idea what the problem is? I'm pretty new to Visual Basic so it's hard to find the problem :S

Thanks in advance

Cheers Daan

Mario Malferrari said...

IsExists() - is a user-defined function... I created it by myself so make sure that it is included in your program...

Dev said...

link expired. can you upload a new one?