VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



In this sample code you will know how to connect to the database using microsoft Jet Oledb 4.0.

by Catherine Poncio (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 9th March 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)

In this sample code you will know how to connect to the database using microsoft Jet Oledb 4.0.

API Declarations


dim rs as new adodb.recordset
dim txt as control
dim inptbx as string
dim sql as string


Rate In this sample code you will know how to connect to the database using microsoft Jet Oledb 4.0.



Dim txt As Control
Private Sub Command1_Click()
Dim db As New adodb.CONNECTION
Dim rs As New adodb.Recordset
Dim sql As String
Dim inptbx As String

   
   inptbx = InputBox("Enter The First Name of the Student")
    sql = "select * from tablenames where FirstName='" & inptbx & "'"
    
     db.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                        "Data Source=" & App.Path & "\namedatabase.mdb"
     db.Open
    rs.Open sql, db, adOpenKeyset, adLockPessimistic, adCmdText
    


    
    

End Sub

Private Sub Command2_Click()
Dim dbs As New adodb.CONNECTION
Dim rss As New adodb.Recordset
    
    dbs.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                          "Data Source=" & App.Path & "\namedatabase.mdb"
    dbs.Open
    
    rss.Open "select * from  tablenames", dbs, adOpenKeyset, adLockPessimistic, adCmdText
    
With rss
.AddNew
.Fields!FirstName = Form1.txtFirstName
.Fields!LastName = Form1.txtLastName
.Fields!MiddleName = Form1.txtMiddleName
.Update
    MsgBox "Saving", vbInformation
End With
End Sub

Private Sub Command3_Click()
For Each txt In Form1
    If TypeOf txt Is TextBox Then
    txt = ""
    txtFirstName.SetFocus
    End If
Next
End Sub

Private Sub Command4_Click()
Unload Me

End Sub


Download this snippet    Add to My Saved Code

In this sample code you will know how to connect to the database using microsoft Jet Oledb 4.0. Comments

No comments have been posted about In this sample code you will know how to connect to the database using microsoft Jet Oledb 4.0.. Why not be the first to post a comment about In this sample code you will know how to connect to the database using microsoft Jet Oledb 4.0..

Post your comment

Subject:
Message:
0/1000 characters