cancel
Showing results for 
Search instead for 
Did you mean: 

connecting to an old access (pre 2003) database with security.mdw file for login authentication

Former Member
0 Kudos

Hi

I am new to the site and crystal reports.  I am using crystal reports for vs 2010 and programming in c#

I have an old database which has user login credentials stored in a separate database (workgroup security?). I can connect to it via c# by passing the login details to the .mdw file and the main database in the connection string.

I can also (in design view) connect to the database and produce a report.

However when I try running the report at runtime, I am being asked for login details... and even after providing the details is does not connect..

I connect using this method in design time:

settings

but i cannot find any information on how to connect at runtime...  Where do I set the session username, session password and system database?

my code to connect looks a bit like this:

          ReportDocument cryRpt = new ReportDocument();

          TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();

          TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();

          ConnectionInfo crConnectionInfo = new ConnectionInfo();

          Tables CrTables;

            string path = Application.StartupPath;

            cryRpt.Load(path + "\\" + report);

           crConnectionInfo.UserID = "someuser";

            crConnectionInfo.Password = "password";

            crConnectionInfo.ServerName = "z:\\main_database.mdb";

          

            CrTables = cryRpt.Database.Tables;

            foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)

            {

                crtableLogoninfo = CrTable.LogOnInfo;

                crtableLogoninfo.ConnectionInfo = crConnectionInfo;

                CrTable.ApplyLogOnInfo(crtableLogoninfo);

            }

            if (parameter != "")

                cryRpt.SetParameterValue(parameter, value);

           crvMain.ReportSource = cryRpt;

           

          

I am losing the will to live trying to find the solution to this, can anyone help??

Cheers

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hello Andrew

This is going back a ways...

I don't believe CR ever supported MDW security at runtime, when using native connection. I think - think - that this might work if you connect via ODBC though... Your code would be something like this:

''CR Variables
    Dim crDatabase As Database
    Dim crTables As Tables
    Dim crTable As Table
    Dim crTableLogOnInfo As TableLogOnInfo
    Dim crConnectionInfo As ConnectionInfo

         crReportDocument.load(<path to a report>)

        'Setup the connection information structure to be used to log onto the datasource for the report.
        crConnectionInfo = New ConnectionInfo()
        With crConnectionInfo
            .ServerName = "poke"   ODBC datasource

            .DatabaseName = "northwind"
            .UserID = "sa"
            .Password = "sa"
        End With

        'Get the table information from the report
        crDatabase = crReportDocument.Database
        crTables = crDatabase.Tables

        'Loop through all tables in the report and apply the connection
        'information for each table.
        For Each crTable In crTables
            crTableLogOnInfo = crTable.LogOnInfo
            crTableLogOnInfo.ConnectionInfo = crConnectionInfo
            crTable.ApplyLogOnInfo(crTableLogOnInfo)
        Next

        'Set the viewer to the report object to be previewed.
        CrystalReportViewer1.ReportSource = crReportDocument

Alternatively, you could download the db code writing utility note in KBA 1553921 - Is there a utility that would help in writing database logon code?

You could even see what it gives you going native...

The utility uses the InProc RAS SDK. More info on this SDK is in the document How to Use The RAS SDK .NET With In-Process RAS Server

And the following Developer Help files may also be useful for InProc RAS SDK:

Report Application Server .NET SDK Developer Guide

Report Application Server .NET API Guide

- Ludek

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Share Your Knowledge in SCN Topic Spaces

Former Member
0 Kudos

Hi

I managed to get the code running, from the utility, but even though the settings look ok, it is failing to login... doh...

Answers (0)