Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

DataGrid and ADO stuff

Hi everyone,

I've been using DataGrid for a while, but I had been using with ADO, so now I need to use the old DAO (because ADO doesn't support crosstab queries) but the thing is that TDBGrid doesn't show me any data of the DAO Recordset and it appears a error message: "Type mistmatch", my code is something like this:

Dim db_current As Database
Dim db_qd As QueryDef
Dim db_rs As Recordset

Set db_current = OpenDatabase("c:\example_db.mdb")

Set db_qd = db_current.CreateQueryDef("")
With db_qd
.SQL = "SELECT * FROM table_example"
Set db_rs = .OpenRecordset()
End With

Set dataGrid1.DataSource = db_rs
' Call dataGrid1.Refresh

What is missing? or what am I doing wrong?
[773 byte] By [nmxnmx] at [2007-11-11 9:56:11]
# 1 Re: DataGrid and ADO stuff
Try fully qualifing your objects like:
Dim db_rs As DAO.RecordSet

If you still get the error then the TDBGrid probably does not support DAO Recordsets.
Ron Weller at 2007-11-11 17:23:35 >
# 2 Re: DataGrid and ADO stuff
thank you for your reply Ron, but I've try with:

Dim db_rs as DAO.RecordSet

but I have with the same error :(
nmxnmx at 2007-11-11 17:24:35 >
# 3 Re: DataGrid and ADO stuff
Well the problem were the wildcards I was using in the crosstab query, I was using * instead of %

So it seems ADO do support crosstab.

Thank you all for your replies :)
nmxnmx at 2007-11-11 17:25:33 >