Loading

Tuesday, March 22, 2011

How to Use ADO Object to get data from a read only MS Access database


'How to Use ADO object to get data from a read-only MS Access database
'In the ConnDataect string, set Mode to Read.

Dim ConnData As ADODB.Connection

' Open a ConnDataection.
Set ConnData = New ADODB.Connection
ConnData.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & db_file & ";" & _
    "Mode=Read;" & "PeRecordset1ist Security Info=False"
ConnData.Open

'This example reads data and displays the values in a List Box object.

Dim Recordset1 As ADODB.Recordset

' Open the Database Recordset.
Set Recordset1 = ConnData.Execute("SELECT * FROM Books", , adCmdText)

' List the data.
Do While Not Recordset1.EOF
    ' The following statement would cause an
    ' error because the ConnDataection is read-only.
    '   Recordset1!Title = "XXX"

    txt = ""
    For Each fld In Recordset1.Fields
        txt = txt & Trim$(fld.Value) & vbTab
    Next fld
    If Len(txt) > 0 Then txt = Left$(txt, Len(txt) - 1)
    List1.AddItem txt
    Recordset1.MoveNext
Loop

Recordset1.Close
ConnData.Close

SHARE TWEET

Thank you for reading this article How to Use ADO Object to get data from a read only MS Access database With URL http://x-tutorials.blogspot.com/2011/03/how-to-use-ado-object-to-get-data-from.html. Also a time to read the other articles.

0 comments:

Write your comment for this article How to Use ADO Object to get data from a read only MS Access database above!