-
Mar 14th, 2001, 11:09 AM
#1
Thread Starter
Hyperactive Member
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.
-
Mar 14th, 2001, 12:08 PM
#2
Addicted Member
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
-
Mar 14th, 2001, 12:52 PM
#3
Thread Starter
Hyperactive Member
Thanks, but the new data control (ADODC) doesn't have a database name property.
-
Mar 14th, 2001, 12:55 PM
#4
Addicted Member
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
|