anhnguyen1999
Programmer
I need to create a report (Crystal Report) which my data source is a recordset that I got after call OpenResultset(sSQL).
My sSQL is actually different each time depend on what report I run.
How can I add that recordset to be my data source and use it in my report?
'************************************
Private Sub Form_Load()
Dim sSQL As String
Dim rdoTest As rdoResultset
Dim en As rdoEnvironment
Dim conn As String
Set en = rdoEnvironments(0)
conn = "DRIVER={Pervasive ODBC Engine Interface};" _
& "DATAPATH=c:\Mydata;" & "DDFPATH=c:\Mydata;" _
& "ACCESSFRIENDLY=yes;"
Set cn = en.OpenConnection(dsName:="Mydata", _
Prompt:=rdDriverComplete, _
Connect:=conn)
sSQL = "SELECT Departments.Department, Departments.DeptCode, INVENTORY.Description, INVENTORY.ItemID
FROM (Departments INNER JOIN IVENTORY ON Departments.DeptCode = INVENTRY.DeptCode)
Set rdoTest = cn.OpenResultset(sSQL)
' Can I use this line below and in my Crystal report at
' design time I will add data source chosing ODBC -> RDO
' ->SQL and build a temp table.
Report.Database.SetDataSource rdoTest, 3, 1
End Sub
'*****************************
Thanks for any input.
My sSQL is actually different each time depend on what report I run.
How can I add that recordset to be my data source and use it in my report?
'************************************
Private Sub Form_Load()
Dim sSQL As String
Dim rdoTest As rdoResultset
Dim en As rdoEnvironment
Dim conn As String
Set en = rdoEnvironments(0)
conn = "DRIVER={Pervasive ODBC Engine Interface};" _
& "DATAPATH=c:\Mydata;" & "DDFPATH=c:\Mydata;" _
& "ACCESSFRIENDLY=yes;"
Set cn = en.OpenConnection(dsName:="Mydata", _
Prompt:=rdDriverComplete, _
Connect:=conn)
sSQL = "SELECT Departments.Department, Departments.DeptCode, INVENTORY.Description, INVENTORY.ItemID
FROM (Departments INNER JOIN IVENTORY ON Departments.DeptCode = INVENTRY.DeptCode)
Set rdoTest = cn.OpenResultset(sSQL)
' Can I use this line below and in my Crystal report at
' design time I will add data source chosing ODBC -> RDO
' ->SQL and build a temp table.
Report.Database.SetDataSource rdoTest, 3, 1
End Sub
'*****************************
Thanks for any input.