Results 1 to 4 of 4

Thread: Using OLE DB grid and data control

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Hi,
    I'm using a grid control (dbgrid32.ocx) along with intristic data control. As I understand I should be using the new versions of both data control and grid control (I think it's called OLE DB).

    Can someone show me a sample of linking Access97 database to the new OLE DB grid through the new OLE DB data control?

    Thanks.
    Thanks

    Tomexx.

  2. #2
    Addicted Member Quintonir's Avatar
    Join Date
    Mar 2001
    Location
    The Netherlands
    Posts
    155

    Post Half-answer

    I am afraid that my attempt on making a database application also ran on the cliffs. But I do can give you a starting point, the simplified short basics.

    First, place the grid control (simply call it grdMyGrid) and data control (datMyData) on your form (frmDB). First of all, you need to 'link' the grid control to the data control. This by using the property DataSource of our grdMyGrid. So, in your properties window, set the DataSource property to datMyData (you can select it from a list). Now the grid control is connected. The data control needs to know where to get his information. The control has a property for this: DatabaseName. When equal to the complete path of our *.mdb file, he knows where to get his information. Let's say it's located at C:\MyDB.mdb, put "C:\MyDB.mdb" in the DatabaseName property. Ok, done. Now, I will show you a little example of code that requests information out of the database with SQL. Of course, I'll assume that the database has a table named "Friends". It could be any name, as long as it's in the database .

    Private Sub Form_Load()

    datMyData.RecordSource = "select * from friends"
    datMyData.Refresh

    End Sub

    Now the grid control should show you all contents of the table Friends. The "select * from friends" is SQL (it says 'give me * (=everything) from the table called Friends'). I recommend you to learn more of this somewhere else, as I'm no expert in SQL. This is the simpelest example there is (when it worked of course, but I really hope so).
    On the first line, the data control sets his SQL command in given property. Then, it refreshes on the second line, displaying every record of this table.
    Tip: On the "*" you should give the column name. I chose to show every column, but let's say you want to show the column "Birthday", simply replace the "*" by "Birthday".)

    I hope this will help with your problem,


    Quintonir

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Thanks, but the new data control (ADODC) doesn't have a database name property.
    Thanks

    Tomexx.

  4. #4
    Addicted Member Quintonir's Avatar
    Join Date
    Mar 2001
    Location
    The Netherlands
    Posts
    155
    Humor ...

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