Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TDBGrid and ADODB connection

Status
Not open for further replies.

MadCatmk2

Programmer
Oct 3, 2003
145
GB
Hi all

I've had very little luck in finding a solution to my problem. From what i can see it should be relatively simple. I am looking to populate a Tru DB grid from a ADODB record set but i cannot get it working. The code i have so far is this and i thought that this is all that would be required.

Option Explicit
Private cn As ADODB.Connection 'this is the connection
Private rst As ADODB.Recordset 'this is the recordset

Private Sub Form_Load()

Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source= T:\CIS Version Control Database\CISVersionControl.mdb"


cn.Open
cn.CursorLocation = adUseClient


Set rst = New ADODB.Recordset


rst.Open "sitedetails", cn, adOpenKeyset, adLockPessimistic, adCmdTable
TDBGrid1.DataSource = rst
TDBGrid1.Refresh

End Sub

Sitedetails is the table within the database that is opened via the connectionstring cn.

Any help would be much appreciated.

Thanks
 
Usually when setting a datasource you should write something like this:

SET TDBGrid1.DataSource = rst

Check it out!!
 
Thanks for the quick reply. I tried that but it didn't work. After looking at it i did however find out what was wrong. I was using the component TDBGrid but when i tried the same code with the component Tdbgrid (OLEDB) it worked fine. I overlooked that.

Thanks for your help once again.
 
Aha! yes u used the lite version which does not except the recordset!

Doesn't matter as long as you found the answer

goodluck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top