Subreport - Datasource

Hi Experts,
The below code is on BO support site. It sets datasource of a subreport to an mdb file. How can I change it to read from SQL 2000?

Public Sub AddSubreportDatabase()
        Dim crDBTables As CRAXDRT.DatabaseTables
        Dim sDatabasePath As String
        Dim sTableName As String
        Set crDBTables = rptSubReport.Database.Tables
        sDatabasePath = App.Path & "\Company.mdb"
        sTableName = "Orders"
        crDBTables.Add sDatabasePath, sTableName
        With rptSubReport.Sections
        .Item("RHa").Suppress = True
        .Item("RHb").Suppress = True
        .Item("RFa").Suppress = True
        .Item("RFb").Suppress = True
        End With
End Sub
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crTable.SetLogOnInfo "Server2", "master", "admin ", "admin"
crTable.Location = "master.dbo.authors2"


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
feesuAuthor Commented:
Hi EwaldL,
The code you sent is for an existing report, that already has a table. In my case i need to add a new table. Then set its location. And it still gives an error.

        Set crDBTables = rptSubReport.Database.Tables
        sDatabasePath = App.Path & "\Company.mdb"
        sTableName = "qr_client_products_test"
        crDBTables.Add sDatabasePath, sTableName
        crDBTables.Item(1).SetLogOnInfo "SRV", "Gl", "sa", "sa"
        crDBTables.Item(1).Location = "Gl.dbo.products"

It doesn't stop on any of the lines, but finally instead of showing the report in the viewer, it says "file not found"
Just help me understand please. If you are creating the report from scratch, by bother changing the datasource? Can you now just create it from scratch connecting to the datasource you want to use at the time right away?

This explains how to create an sql server report from scratch using a native connection

Native is not supported anymore in Crsytal xi, not sure which version you have. If you need to change it to OLE DB, then the ODBC name in code needs to be replaced with the SQL SErver instance name and the dll name that needs to be coded hsould be crdb_oledb.dll
feesuAuthor Commented:
You're right. Thanks alot.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.