Larry Rungren
asked on
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
Crystalcreds.docx
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
Crystalcreds.docx
ASKER
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?
mlmcc
Are you using the CR Version for VS2010 or a standalone Crystal?
mlmcc
ASKER
The form has a crystalreportviewer " crystalreportviewer1"
The report is on a server, and runs from crystal 2011 IDE and when called from VB6
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
--
report.Load(j:\crystalreports\evaluations\completedseminaranalysis.rpt")
--
-- “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)
Next
‘CrystalReportViewer1.RefreshReport()
Private Sub CrystalReportViewer1_Load(sender As System.Object, e As System.EventArgs) Handles CrystalReportViewer1.Load
End Sub
End Class
Was the report built against a database originally?
mlmcc
mlmcc
ASKER
Yes There are several reports in this application. Some use files as a data source, some use stored proc edures
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
Have a great weekend.
ASKER
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.
mlmcc
mlmcc
ASKER
In VB6 the code is:
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
Set Cry = New CRAXDRT.Application
Set Rep = Cry.OpenReport _
("j:\CrystalReports\Evalua tions\comp letedsemin aranalysis .rpt")
Rep.Database.LogOnServer "p2sodbc.dll", "iMIS___MCLE-APP_iMIS15", "imis_mcle_prod", "userid", "password"
Rep.DiscardSavedData
'Rep.ParameterFields(1).Cl earCurrent ValueAndRa nge
'Rep.ParameterFields(1).Ad dCurrentVa lue frmControl.txtProductCode. Text
With CRViewer91
.ReportSource = Rep
.RefreshEx True
.Refresh
.ViewReport
.EnableExportButton = True
End With
Cry.CanClose
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"
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
Set Cry = New CRAXDRT.Application
Set Rep = Cry.OpenReport _
("j:\CrystalReports\Evalua
Rep.Database.LogOnServer "p2sodbc.dll", "iMIS___MCLE-APP_iMIS15", "imis_mcle_prod", "userid", "password"
Rep.DiscardSavedData
'Rep.ParameterFields(1).Cl
'Rep.ParameterFields(1).Ad
With CRViewer91
.ReportSource = Rep
.RefreshEx True
.Refresh
.ViewReport
.EnableExportButton = True
End With
Cry.CanClose
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
http://scn.sap.com/docs/DOC-21971
https://msdn.microsoft.com/en-us/library/ms225492(v=vs.80).aspx
mlmcc
http://scn.sap.com/docs/DOC-21971
https://msdn.microsoft.com/en-us/library/ms225492(v=vs.80).aspx
mlmcc
Just view it
mlmcc