.NET vb db access for crystal report

G

Guest

Hi, I'm using
VB .NET (Visual Studio 2002
Crystal Reports 9 (soon to upgrade to 10, just want 9 to work first
Win 200

When I run the crystal report independently, I can access the Oracle 7.3.4 database, no problem. db name PDTT, uid and pwd

But, when I run it via the vb .net app, it is only reading the memory of the data in the report, and therefore when I try to run a parameter, it fails. It calls me to insert server name, it defaults to the db name and uid and calls for a pwd. Why is this happening? What am I doing wrong

I call the report from form1 which initializes the RD component , and the CR Viewer on form2 calls the PDTTtest.rpt
When I click refresh in debug mode, I'm asked for the server name, etc

I can visually see the db tables listed in VStudio .net. Is this a networking issue? The server resides elsewhere, maybe a domain/router/security prob? Yet, if so, why can I connect using the report alone

I'd really appreciate your help. I've put this request out in a few places, am not getting feedback, need to move forward asap!!

(a) I need to be able to run the report in the app, and
(b) I want to set it up so the user isn't prompted to log in each time.
 
B

Bernie Yaeger

Hi Helen,

Below is a sub I created to automate uid, pwd, server name, etc, mostly so
that my clients' servers have to be accessed instead of my test server. I'm
using sql server 2000, but this should work for you as well. I call this
sub before loading the crystalreportviewer with the necessary data, which is
done at the end of the sub.

Let me know if you have further questions.

HTH,

Bernie Yaeger
Public Sub connectionchange()

If gl_browseprintvar = "f:\imcapps\rtffiles\rtfprin2.rpt" Then

CrystalReportViewer1.ReportSource = gl_browseprintvar

Exit Sub

End If

'Dim crreportdocument As New ReportDocument

Dim crtablelogoninfos As New TableLogOnInfos

Dim crtablelogoninfo As New TableLogOnInfo

Dim crconnectioninfo As New ConnectionInfo

Dim crtables As Tables

Dim crtable As Table

Dim tablecounter As Integer

crreportdocument.Load(gl_browseprintvar,
OpenReportMethod.OpenReportByTempCopy)

With crconnectioninfo

..DatabaseName = "IMC"

..ServerName = globalservername

..UserID = globalusername

..Password = globalpwd

End With

crtablelogoninfo.ConnectionInfo = crconnectioninfo

crtables = crreportdocument.Database.Tables

For Each crtable In crtables

'///

If (Mid(crtable.Name, 1, 4) = "magt" Or Mid(crtable.Name, 1, 4) = "magb" Or
Mid(crtable.Name, 1, 4) = "magf") And gl_browseprintvar =
"f:\imcapps\hvsum.rpt" Then

crconnectioninfo.DatabaseName = "imc_extra"

crtablelogoninfo.ConnectionInfo = crconnectioninfo

Else

crconnectioninfo.DatabaseName = "IMC"

crtablelogoninfo.ConnectionInfo = crconnectioninfo

End If

'///

' crtablelogoninfo = crtable.LogOnInfo

' crtable.LogOnInfo.ConnectionInfo = crconnectioninfo

crtable.ApplyLogOnInfo(crtablelogoninfo)

crtable.Location = crtable.Name

'MessageBox.Show(crconnectioninfo.ServerName)

'MessageBox.Show(crtable.LogOnInfo.ConnectionInfo.ServerName)

Next

Dim subRepDoc As New ReportDocument

Dim crSection As Section

Dim crReportObject As ReportObject

Dim crSubreportObject As SubreportObject

'If you have any sub-reports, they need the connection info too...

For Each crSection In crreportdocument.ReportDefinition.Sections

For Each crReportObject In crSection.ReportObjects

If crReportObject.Kind = ReportObjectKind.SubreportObject Then

crSubreportObject = CType(crReportObject, SubreportObject)

subRepDoc = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

For Each crtable In subRepDoc.Database.Tables

crtable.ApplyLogOnInfo(crtablelogoninfo)

crtable.Location = crtable.Name

Next

End If

Next

Next

'If CrystalReportViewer1.ParameterFieldInfo.Count > 0 Then

' CrystalReportViewer1.ShowRefreshButton = False

'End If

CrystalReportViewer1.ReportSource = crreportdocument

End Sub

Helen said:
Hi, I'm using
VB .NET (Visual Studio 2002)
Crystal Reports 9 (soon to upgrade to 10, just want 9 to work first)
Win 2000

When I run the crystal report independently, I can access the Oracle 7.3.4
database, no problem. db name PDTT, uid and pwd.
But, when I run it via the vb .net app, it is only reading the memory of
the data in the report, and therefore when I try to run a parameter, it
fails. It calls me to insert server name, it defaults to the db name and uid
and calls for a pwd. Why is this happening? What am I doing wrong?
I call the report from form1 which initializes the RD component , and the
CR Viewer on form2 calls the PDTTtest.rpt.
When I click refresh in debug mode, I'm asked for the server name, etc.

I can visually see the db tables listed in VStudio .net. Is this a
networking issue? The server resides elsewhere, maybe a
domain/router/security prob? Yet, if so, why can I connect using the report
alone?
I'd really appreciate your help. I've put this request out in a few
places, am not getting feedback, need to move forward asap!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top