|
-
May 1st, 2000, 02:06 AM
#1
Thread Starter
New Member
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.
-
May 1st, 2000, 02:17 AM
#2
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.
-
May 1st, 2000, 02:22 AM
#3
Thread Starter
New Member
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?
-
May 1st, 2000, 02:58 AM
#4
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
-
May 1st, 2000, 03:07 AM
#5
Hyperactive Member
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.
-
May 1st, 2000, 03:20 AM
#6
OK, and which Grid are you using?? What is it exactly that you are trying to show in your app??
-
May 1st, 2000, 03:25 AM
#7
Hyperactive Member
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...
-
May 1st, 2000, 03:53 AM
#8
OK, I'll give it a try and let you know if I came up with a solution ASAP.
Imar
-
May 1st, 2000, 04:16 AM
#9
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
-
May 1st, 2000, 04:19 AM
#10
Hyperactive Member
Sounds like exactly what I need, thanks again for your help.
-
May 1st, 2000, 04:41 AM
#11
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
-
May 1st, 2000, 04:57 AM
#12
Hyperactive Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|