Passing auth info for sql 2008 to crystal report from vb2010

I have a crystal report that runs in crystal IDE and when called from VB6.
In visual studio 2010 vb I have a form with a report viewer an I have loaded the report into VS. The report runs but every time I run it asks for user name and password.

When the report selection is clicked from menu I .show the form and the report is there, but I have to enter creds.

Is there any way to simply pass the creds and let Crystal do the prompting and report?

Here is the code in the form with the viewer

even though the "report is declared, vb say declaration needed
Larry RungrenDirector of TechnologyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Try your code without the refresh.
Just view it

Larry RungrenDirector of TechnologyAuthor Commented:
Doesn't work,  even though report is dimmed above the "report" in the code section vs says is not defined???
Which line is it pointing to on the error?

Are you using the CR Version for VS2010 or a standalone Crystal?

10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Larry RungrenDirector of TechnologyAuthor Commented:
The form has a crystalreportviewer  " crystalreportviewer1"

The report is on a server, and runs from crystal 2011 IDE and when called from VB6

Imports System.Data.SqlClient
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.CrystalReports.Engine
Public Class frmCompletedSeminar
    Dim report As New ReportDocument
    Dim connection As String
    Dim ServerName As String = ".mcle_sql2008\mcle_sql2008"
    Dim DatabaseName As String = "imis_mcle_prod"
    Dim UserID As String = "sa"
    Dim Password As String = "donaldduck"
    Dim subreport As ReportDocument
-- “report” below (each time used)     says declaration expected
-- “crystalreportviewer1” below says declaration expected
  CrystalReportViewer1.ReportSource = report
  report.DataSourceConnections.SetConnection(ServerName, DatabaseName, UserID, Password)

  -- For next loop is flagged as syntax error – probably due to the errors above.

  For Each subreport In report.Subreports
     report.subreport.DataSourceConnections.SetConnection(ServerName, DatabaseName, UserID, Password)

    Private Sub CrystalReportViewer1_Load(sender As System.Object, e As System.EventArgs) Handles CrystalReportViewer1.Load

    End Sub
End Class

Open in new window

Was the report built against a database originally?

Larry RungrenDirector of TechnologyAuthor Commented:
Yes  There are several reports in this application.  Some use files as a data source, some use stored proc edures
You may need to rebuild the report or at least change its data source to a dataset/xml file.
I believe until you do that it will always want to log into the database.
Assuming the database exists you could change the code to provide that log in.


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
Larry RungrenDirector of TechnologyAuthor Commented:
I will do some research on how to do the change of datasource, but to be truthful, to break a process that has been running for 15 years because SAP and MSFT can't get along proves these guys don't give a damn about the existing user base.  I truly appreciate your assistance and direction. Now I'll have to go about modifying 18 reports and how they are run from VS2010

Have a great weekend.
Larry RungrenDirector of TechnologyAuthor Commented:
Not what I was hoping to hear, but it is what it is.  Too bad these outfits don't have the financial restraints that small business has, maybe there would be more consideration in breaking things every time they feel it is in their interest.
It may be as simple as creating the dataset then using the SET DATA SOURCE LOCATION option in the designer to change to the new source.

Larry RungrenDirector of TechnologyAuthor Commented:
In VB6 the code is:

Private Sub Form_Load()

    Screen.MousePointer = vbHourglass
    Set Cry = New CRAXDRT.Application
    Set Rep = Cry.OpenReport _
    Rep.Database.LogOnServer "p2sodbc.dll", "iMIS___MCLE-APP_iMIS15", "imis_mcle_prod", "userid", "password"
    'Rep.ParameterFields(1).AddCurrentValue frmControl.txtProductCode.Text
    With CRViewer91
        .ReportSource = Rep
        .RefreshEx True
        .EnableExportButton = True
    End With
        Set Cry = Nothing
    Screen.MousePointer = vbDefault
End Sub

In vs:

1. I create a form and put a reportviewer on it.
2. I load the external report into the viewer and save as part of the project.
3. From menu I click the report I want that shows the form.
4. On load the form shows the reportviewer, and at this point I am prompted for the password for the database.

If I enter the password, the report prompts me for parameters correctly and runs the report flawlessly.

There must be a simple replacement for this code to allow the rport direct access to the database without prompting!

  Rep.Database.LogOnServer "p2sodbc.dll", "iMIS___MCLE-APP_iMIS15", "imis_mcle_prod", "userid", "password"
Check these documents on migrating from the VB6 to .Net assemblies

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.