Save, Edit and Delete Example into Access Database Using VB6.0

‘——————————————————————-

‘ Instraction For Safe Project Load

‘ Components Add Your Project

‘ 1) Add Microsoft ADO Data Control 6.0 (OLEDB)

‘ 2) Add Microsoft Windows Commom Controls-2.6 Your Project

‘——————————————————————-

Dim db As ADODB.Connection

Dim rst As ADODB.Recordset

Dim id As Integer

Private Sub Form_Load()

‘Open Database Connection

Set db = New ADODB.Connection

db.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\s4sajoy SampleCode\SampleDB.mdb;Persist Security Info=False”

Set rst = New ADODB.Recordset

rst.Open “select * from tblSample Order By SerialNo DESC”, db, adOpenStatic, adLockOptimistic, adCmdText

If rst.RecordCount = 0 Then

id = 1

Else

id = rst(“SerialNo”) + 1

End If

rst.Close

lblID.Caption = id

End Sub

 

Private Sub cmdAdd_Click()

If Trim(txtName.Text) = “” Then

MsgBox “input name”, vbInformation

Else

Set rst = New ADODB.Recordset

rst.Open “select * from tblSample”, db, adOpenStatic, adLockOptimistic, adCmdText

rst.AddNew

rst(“SerialNo”) = CInt(lblID.Caption)

rst(“Date”) = DTPicker1.Value

rst(“Name”) = Trim(txtName.Text)

rst.Update

rst.Close

MsgBox “One Person Added.” & Chr(13) & “Nmae : ” & Trim(txtName.Text), vbInformation

id = id + 1

lblID.Caption = id

DTPicker1.Value = Date

txtName.Text = “”

txtName.SetFocus

End If

End Sub

Private Sub cmdUpdate_Click()

If Trim(txtID.Text) = “” Then

MsgBox “input id no”

txtID.SetFocus

Else

Set rst = New ADODB.Recordset

rst.Open “UPDATE tblSample SET tblSample.Date = #” & DTPicker1.Value & “#, tblSample.Name = ‘” & txtName.Text & “‘ WHERE tblSample.SerialNo=” & txtID.Text, db, adOpenStatic, adLockOptimistic, adCmdText

MsgBox “One Row Updated”

End If

End Sub

Private Sub cmdDelete_Click()

If Trim(txtID.Text) = “” Then

MsgBox “input id no”

txtID.SetFocus

Else: Set rst = New ADODB.Recordset

rst.Open “Delete * From tblSample Where SerialNo=” & txtID.Text, db, adOpenStatic, adLockOptimistic, adCmdText

MsgBox “Delete Successfull”

End If

End Sub

Download [Sample Code]

Advertisements

16 thoughts on “Save, Edit and Delete Example into Access Database Using VB6.0

  1. Pingback: Add and Delete Record in Database Using access 2010 and vb 2010 | Sanjoy's Blog

  2. Please help

    I’m still getting message error
    ==========
    Compile error:
    Expected : End Of statement (at &)
    ==========

    Private Sub Command2_Click()

    If Trim(txtpend.Text) = “” Then

    txtpend.SetFocus

    Else: Set rst = New ADODB.Recordset

    rst.Open “Delete * From TableReg Where No=” & txtpend.Text, regcnn, adOpenStatic, adLockOptimistic, adCmdText

    MsgBox “Delete Successfull”

    End If
    End Sub

  3. sir i’m samim ali ,student of brainware.my vb is very week but i’m doing the project of library management .i’m faceing some problem when i’m going for coding.so sir please help me to complete this project.i’m faceing problem in the following form:
    1.book issue
    2.return book
    3.i want to fetch books from data base to combo box for deletion .

  4. A melancholy is the area inside a tooth that remaining parts after tooth rot is uprooted.
    Plaque, a dreary, sticky film of microbes that constantly structures on tooth, is a single
    of the elementary driver of tooth rot. The reason we brush and floss regularly is to uproot plaque, on the grounds that microbes in plaque responds with sugar in the nourishments
    we take in to generate acids that can assault and debilitate tooth lacquer
    the challenging, defensive blanket on our tooth.
    Disintegrating polish leaves the enamel unprotected, using into account holes to develop
    all the more properly.

    On the gnawing surfaces of the teeth. This transpires when plaque receives
    to be caught in the notches or cleft of the tooth. This is most
    typical in kids, in light of the truth that they frequently miss these ranges when brushing.

    This occurs when plaque is still left to build on the tough-to-achieve
    surfaces. These regions can’t be arrived at by a toothbrush by itself and might be
    defenseless to rot on the off likelihood that you don’t floss or clear between your tooth, typically.

    This is standard in the occasion that you have endured gum subsidence or bone misfortune,
    regularly connected with gum illness, or periodontitis.
    It really is additionally much more standard to learn rot here as
    you get more proven if your gums retreat. On the off opportunity
    that plaque is left to produce on the uncovered bases of the teeth, then a hole can quickly develop in light-weight of the fact that roots don’t have the very same
    challenging veneer coating.

    Fortunately, there are quite a few things you
    can do to help keep the generation of a pit. Endeavor this dental specialist suggested oral forethought routine:

    Use toothpaste or mouthwash containing fluoride, an executor that fortifies tooth and aides anticipate pits

    Just take right after a strong consuming methodology and dodge sugary sustenances
    and drinks

    Strategy standard visits with your dental
    practitioner, fairly virtually at normal intervals, for a schedule cleaning and exam

    Keep in thoughts to alter your toothbrush when it appears worn, or at typical intervals, on the grounds that the a lot more recent the abounds,
    the a lot more plaque the brush has the capability uproot

    You ought to anticipate looking at your dental practitioner 2
    times a yr for checkups. Even though checkups can shift, your
    dental practitioner will doubtlessly examine your enamel and
    gums for any clear troubles, such as the enhancement of a melancholy.
    He or she may well furthermore just take X-beams to verify there are not any troubles that are not however noticeable.
    Your dental expert may possibly additionally skillfully
    clear your enamel to expel solidified plaque from earlier mentioned
    and underneath the gum line, and shine them to expel plaque
    and stains from the tooth floor. Also keep in mind your dental specialist can similarly
    give master path on brushing and flossing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s