Results 1 to 12 of 12

Thread: DBGrid unbound

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 1999
    Location
    Clark County Washington
    Posts
    6
    I am trying to display data on a DBGrid in unbound mode. In other words I want to supply the data programtically. I am having trouble figuring out how to fill in the columns and rows with my data however. How is this done? Question sounds simple so hopefully someone knows... There don't seem to be any addrow or addcolumn methods but the help claims that unbound mode is the way to go just doesn't expound on how to go about it. Thanks.

  2. #2
    Guest
    I hardly worked with the DBGrid, but is it a possibility to create a recordset programatically and assign that to your DBGrid? It's relatively easy to create your own custom recordset without a DB connection.

    I'd say that should work, because there should be no difference between a "real" recordset and a dynamically created one.

    Imar.


  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 1999
    Location
    Clark County Washington
    Posts
    6
    That brings up another question... How do you set a Grid control to a recordset at runtime. I thought most those had to be set at design time?

  4. #4
    Guest
    Can you tell me which controls or objects you are using?? Some source might also come in handy. It's been a while since I worked with a grid control, but I may be able to help you.

    Imar

  5. #5
    Hyperactive Member scuzymoto's Avatar
    Join Date
    Aug 1999
    Location
    Washington State
    Posts
    316
    Disregard, Scuzy. I didn't realize I had two different user names... Anyway this is how I am trying to set it up...

    (referencing DAO 3.51 object library)

    Dim dbData As Database
    Dim rsData As Recordset

    Set dbData = OpenDatabase(cUserInputDatabase)
    Set rsData = dbData.OpenRecordset(cUserInputQuery)

    Now I want to display the query.

    BTW Im not using any database control components. I want to work strictly with code from the DAO library, because other parts of my application conflict with the data control components.
    SCUZ

  6. #6
    Guest
    OK, and which Grid are you using?? What is it exactly that you are trying to show in your app??

  7. #7
    Hyperactive Member scuzymoto's Avatar
    Join Date
    Aug 1999
    Location
    Washington State
    Posts
    316
    I just want to simply display the contents of the recordset. The Grid I am using is really none of them yet because I havent gotten any of them to work. I have tried dbgrid, datagrid, flexgrid etc.. I would be happy with any of them if I could just get it to display the contents of the recordset. The catch is that the database nor the recordset are available until runtime.

    Thanks by the way for helping...
    SCUZ

  8. #8
    Guest
    OK, I'll give it a try and let you know if I came up with a solution ASAP.

    Imar

  9. #9
    Guest
    If you want I can show you some basic code to create a custom recordset (using ADO), fill it with a few columns, add a couple of records to the recordset and then assign the whole to a datasource to display it.
    This would all be very basic. Just create a two or three column recordset and display it. No fancy drill down stuff

    Is this what you need???


    Imar

  10. #10
    Hyperactive Member scuzymoto's Avatar
    Join Date
    Aug 1999
    Location
    Washington State
    Posts
    316
    Sounds like exactly what I need, thanks again for your help.
    SCUZ

  11. #11
    Guest
    OK, here we go.

    Start up a new project and add references to Microsoft Active X Data Objects 2.1 (or higher).

    Add a reference to the Microsoft Datagrid controls 6.0 through Components.

    Add the following code to a button, or whatever:

    ' Sample one: creating a custom recordset, (not database driven)
    Dim rsLog As ADODB.Recordset
    Set rsLog = New ADODB.Recordset
    rsLog.Fields.Append "Ordernumber", adVarChar, 10
    rsLog.Fields.Append "OrderID", adInteger
    rsLog.Open
    rsLog.AddNew Array("Ordernumber", "OrderID"), Array("A1234", 100)
    Set DataGrid1.DataSource = rsLog

    I think the difference with what you had is th Set DataGrid1.DataSource = instead of DataGrid1.DataSource =

    Hope this helps.
    Let me know if you need help with a data driven example as well.


    Imar


  12. #12
    Hyperactive Member scuzymoto's Avatar
    Join Date
    Aug 1999
    Location
    Washington State
    Posts
    316
    Imar, cant thank you enough for your time... This will ulitmately give me what I need. When I try to link the grid directly to my recordset I am still getting an error but I can take my recordset and translate it into the dynamic set you gave me and still get what I want in the end so thats good enough for me. Thanks again.
    SCUZ

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