Results 1 to 6 of 6

Thread: Help with Data object please!

  1. #1

    Thread Starter
    Member vm360's Avatar
    Join Date
    Oct 2001
    Location
    Argentina
    Posts
    52

    Unhappy Help with Data object please!

    How can I open an Access 2000 database using the Data object?
    Thanks.

  2. #2

    Thread Starter
    Member vm360's Avatar
    Join Date
    Oct 2001
    Location
    Argentina
    Posts
    52
    Please gimme some advice...

    If this is not possible using the data object, please tell me another way to use an Access database. I have textbox in which I have to show the content of a field. Any demo or something?

    Thanks.

  3. #3
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    I would recommend using ActiveX data objects. This is Micrsofts
    recommended data access solution for connecting to various datastores. Here's an example. Go into Projects --> References
    -->Microsoft ActiveX Data Objects...Check it

    Code:
    Private Sub Form_Load()
        Dim objConn As New ADODB.Connection
        Dim strConnectionString As String
        
        strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB;Persist Security Info=False"
        objConn.Open strConnectionString
    End Sub
    This only establishes a connection to the database. If you need help retrieving a recordset, let me know. ADO objects are pretty easy to traverse once you get the hang of the object hiearchy.

  4. #4

    Thread Starter
    Member vm360's Avatar
    Join Date
    Oct 2001
    Location
    Argentina
    Posts
    52
    Thanks. I just want to ask you the following:

    I have a multiline textbox and I want to load the contents of the records I have in a field, how can I do it?
    I want to use some buttons to move between the fields.
    If you can please make a little demo for me, I'll appreciate it a lot. I'm learning, be patient with me

  5. #5
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Here's a quick run through on how to navigate thru a recordset. By no means is this complete, just a quick, dirty example.

    Code:
    Option Explicit
    Dim objConn As New ADODB.Connection
    Dim objRS As New ADODB.Recordset
    
    Private Sub cmdMoveNext_Click()
        objRS.MoveNext
        If objRS.EOF Then objRS.MovePrevious
    End Sub
    
    Private Sub cmdMovePrevious_Click()
        objRS.MovePrevious
        If objRS.BOF Then objRS.MoveNext
    End Sub
    
    Private Sub Form_Load()
        Dim strConnectionString As String
        
        strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB;Persist Security Info=False"
        objConn.Open strConnectionString
        
        objRS.Open "Employees", objConn, adOpenStatic, adLockReadOnly, adCmdTable
        Set Text1.DataSource = objRS
        Text1.DataField = "EmployeeID"
    End Sub

  6. #6

    Thread Starter
    Member vm360's Avatar
    Join Date
    Oct 2001
    Location
    Argentina
    Posts
    52
    It's OK.

    Thank you SO much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width