geoenvi
asked on
URGENT-- CRystal reports runtime
I developed a bunch of reports using the designer and setting the datasource as ADO.net and a stored proc. I call it using the follwing Used trusted conneection (integrated security) at runtime. Now after I build the vb.net application, how would I change the conection info at the production environment(?)
Any help is appreciated...
Private Sub showreports_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim rptloc As New locreport()
Dim pvlocID As New CrystalDecisions.Shared.Pa rameterVal ues()
Dim pdvlocIDrange As New _
CrystalDecisions.Shared.Pa rameterDis creteValue ()
pdvlocIDrange.Value = fltrloc
pvlocID.Add(pdvlocIDrange)
rptloc.DataDefinition.Para meterField s _
("@whereclause").ApplyCurr entValues( pvlocID)
crviewer.ReportSource = rptloc
End Sub
Any help is appreciated...
Private Sub showreports_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim rptloc As New locreport()
Dim pvlocID As New CrystalDecisions.Shared.Pa
Dim pdvlocIDrange As New _
CrystalDecisions.Shared.Pa
pdvlocIDrange.Value = fltrloc
pvlocID.Add(pdvlocIDrange)
rptloc.DataDefinition.Para
("@whereclause").ApplyCurr
crviewer.ReportSource = rptloc
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok, Here is what i did:
you can store the connection information in web.config file.
It is easy to change while deploying to production.
-------------------------- ---------- ---------- ---------- --
Step1:
I created Stored procedure at backend SqlServer which handles all my buisness logic and returns final resultsets..
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -----
Step2:
Created a Typed Dataset like this:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="CTCPhoneListDataset"
targetNamespace="http://tempuri.org/CTCPhoneListDataset.xsd"
elementFormDefault="qualif ied"
attributeFormDefault="qual ified"
xmlns="http://tempuri.org/CTCPhoneListDataset.xsd"
xmlns:mstns="http://tempuri.org/CTCPhoneListDataset.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas- microsoft- com:xml-ms data">
<xs:element name="CTCPhoneListDataset" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="CTCPhoneList">
<xs:complexType>
<xs:sequence>
<xs:element name="BureauName" type="xs:string" />
<xs:element name="MemberName" type="xs:string" />
<xs:element name="WorkPhone" type="xs:string" />
<xs:element name="GroupName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
-------------------------- ---------- ---------- ---------- ---------- ------
Note:The element names in the typed dataset above should match with resultset the Stored Proc is returning.
-------------------------- ---------- ---------- ---------- ---------- -------
Step3:
Created Crystal Report(.rpt) and bound the Typed Dataset as datasource in my report.
-------------------------- ---------- ---------- ---------- ---------- --------
Step4: Created a aspx Web page with the following function code:
If ddlSelectExportFormatCOG.S electedVal ue = "PDF" Then
Call ExportPhoneList(".pdf", CrystalDecisions.Shared.Ex portFormat Type.Porta bleDocForm at, "pdf", strGroupNo, strDecisionMakers, strRecoveryExperts, strOperationalStaff, strExecutiveStaff, strEmergencyCertifiedPerso nnel, strVendorSupport, strEPLO)
ElseIf ddlSelectExportFormatCOG.S electedVal ue = "WORD" Then
Call ExportPhoneList(".doc", CrystalDecisions.Shared.Ex portFormat Type.WordF orWindows, "msword", strGroupNo, strDecisionMakers, strRecoveryExperts, strOperationalStaff, strExecutiveStaff, strEmergencyCertifiedPerso nnel, strVendorSupport, strEPLO)
ElseIf ddlSelectExportFormatCOG.S electedVal ue = "EXCEL" Then
Call ExportPhoneList(".xls", CrystalDecisions.Shared.Ex portFormat Type.Excel , "vnd.ms-excel", strGroupNo, strDecisionMakers, strRecoveryExperts, strOperationalStaff, strExecutiveStaff, strEmergencyCertifiedPerso nnel, strVendorSupport, strEPLO)
End If
-------------------------- ---------- ---------- ---------- ---------- --------
Private Function ExportPhoneList(ByVal stFileExtension As String, ByVal expFormat As CrystalDecisions.Shared.Ex portFormat Type, ByVal stContentTyp As String, ByVal GroupNo As String, ByVal DecisionMakers As String, ByVal RecoveryExperts As String, ByVal OperationalStaff As String, ByVal ExecutiveStaff As String, ByVal EmergencyCertifiedPersonne l As String, ByVal VendorSupport As String, ByVal EPLO As String)
Dim MyDate As String = TimeStamp()
'Check for folder if Does not Exists, Create It in("Mydocuments")
Dim oFile As System.IO.File
Dim oFolder As System.IO.Directory
Dim oWrite As System.IO.StreamWriter
If Not oFolder.Exists(filepath & "\OACallListReportFiles") Then
oFolder.CreateDirectory(fi lepath & "\OACallListReportFiles")
End If
Dim tempFileName As String
tempFileName = filepath & "\OACallListReportFiles\" & "PhoneList" & MyDate & stFileExtension
Dim dfo As CrystalDecisions.Shared.Di skFileDest inationOpt ions = New CrystalDecisions.Shared.Di skFileDest inationOpt ions
dfo.DiskFileName = tempFileName
Dim crCTCPhoneListing As CTCPhoneListing
crCTCPhoneListing = New CTCPhoneListing
Dim eo As CrystalDecisions.Shared.Ex portOption s = crCTCPhoneListing.ExportOp tions
eo.DestinationOptions = dfo
eo.ExportDestinationType = CrystalDecisions.Shared.Ex portDestin ationType. DiskFile
eo.ExportFormatType = expFormat
'------------------------- ---------- ---------- ---------- -------
''Build a connection string
Dim strConnection As String = ConfigurationSettings.AppS ettings("C onnectionS tring")
Dim objConnection As New SqlConnection(strConnectio n)
Dim sqlString As String
sqlString = "Execute GetCTCPhoneList "
sqlString = sqlString & "'" & Trim(GroupNo) & "',"
sqlString = sqlString & "'" & Trim(DecisionMakers) & "',"
sqlString = sqlString & "'" & Trim(RecoveryExperts) & "',"
sqlString = sqlString & "'" & Trim(OperationalStaff) & "',"
sqlString = sqlString & "'" & Trim(ExecutiveStaff) & "',"
sqlString = sqlString & "'" & Trim(EmergencyCertifiedPer sonnel) & "',"
sqlString = sqlString & "'" & Trim(VendorSupport) & "',"
sqlString = sqlString & "'" & Trim(EPLO) & "'"
Dim myTable As CrystalDecisions.CrystalRe ports.Engi ne.Table
Dim myLogin As CrystalDecisions.Shared.Ta bleLogOnIn fo
For Each myTable In crCTCPhoneListing.Database .Tables
myLogin = myTable.LogOnInfo
myLogin.ConnectionInfo.Pas sword = ConfigurationSettings.AppS ettings("D evSQLPassw ord") '"oacalllists_test%admin"
myLogin.ConnectionInfo.Use rID = ConfigurationSettings.AppS ettings("D evSQLUserI D") '"oacalllists_tst_adm"
myTable.ApplyLogOnInfo(myL ogin)
Next
Dim da As SqlDataAdapter
da = New SqlDataAdapter(sqlString, objConnection)
Dim ds As New DataSet
da.Fill(ds, "CTCPhoneList")
crCTCPhoneListing.SetDataS ource(ds)
'CleanUp
objConnection.Close()
objConnection = Nothing
crCTCPhoneListing.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = String.Format("application /{0}", stContentTyp)
Response.WriteFile(tempFil eName)
Response.Flush()
Response.Close()
'System.IO.File.Delete(tem pFileName)
End Function
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- --------
If you see my above code, i am getting connection information from web.config file.
no hard coding inside my web page.
-------------------------- ---------- ---------- ---------- -----
Hope it helps. Good Luck.
you can store the connection information in web.config file.
It is easy to change while deploying to production.
--------------------------
Step1:
I created Stored procedure at backend SqlServer which handles all my buisness logic and returns final resultsets..
--------------------------
Step2:
Created a Typed Dataset like this:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="CTCPhoneListDataset"
targetNamespace="http://tempuri.org/CTCPhoneListDataset.xsd"
elementFormDefault="qualif
attributeFormDefault="qual
xmlns="http://tempuri.org/CTCPhoneListDataset.xsd"
xmlns:mstns="http://tempuri.org/CTCPhoneListDataset.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-
<xs:element name="CTCPhoneListDataset"
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="CTCPhoneList">
<xs:complexType>
<xs:sequence>
<xs:element name="BureauName" type="xs:string" />
<xs:element name="MemberName" type="xs:string" />
<xs:element name="WorkPhone" type="xs:string" />
<xs:element name="GroupName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
--------------------------
Note:The element names in the typed dataset above should match with resultset the Stored Proc is returning.
--------------------------
Step3:
Created Crystal Report(.rpt) and bound the Typed Dataset as datasource in my report.
--------------------------
Step4: Created a aspx Web page with the following function code:
If ddlSelectExportFormatCOG.S
Call ExportPhoneList(".pdf", CrystalDecisions.Shared.Ex
ElseIf ddlSelectExportFormatCOG.S
Call ExportPhoneList(".doc", CrystalDecisions.Shared.Ex
ElseIf ddlSelectExportFormatCOG.S
Call ExportPhoneList(".xls", CrystalDecisions.Shared.Ex
End If
--------------------------
Private Function ExportPhoneList(ByVal stFileExtension As String, ByVal expFormat As CrystalDecisions.Shared.Ex
Dim MyDate As String = TimeStamp()
'Check for folder if Does not Exists, Create It in("Mydocuments")
Dim oFile As System.IO.File
Dim oFolder As System.IO.Directory
Dim oWrite As System.IO.StreamWriter
If Not oFolder.Exists(filepath & "\OACallListReportFiles") Then
oFolder.CreateDirectory(fi
End If
Dim tempFileName As String
tempFileName = filepath & "\OACallListReportFiles\" & "PhoneList" & MyDate & stFileExtension
Dim dfo As CrystalDecisions.Shared.Di
dfo.DiskFileName = tempFileName
Dim crCTCPhoneListing As CTCPhoneListing
crCTCPhoneListing = New CTCPhoneListing
Dim eo As CrystalDecisions.Shared.Ex
eo.DestinationOptions = dfo
eo.ExportDestinationType = CrystalDecisions.Shared.Ex
eo.ExportFormatType = expFormat
'-------------------------
''Build a connection string
Dim strConnection As String = ConfigurationSettings.AppS
Dim objConnection As New SqlConnection(strConnectio
Dim sqlString As String
sqlString = "Execute GetCTCPhoneList "
sqlString = sqlString & "'" & Trim(GroupNo) & "',"
sqlString = sqlString & "'" & Trim(DecisionMakers) & "',"
sqlString = sqlString & "'" & Trim(RecoveryExperts) & "',"
sqlString = sqlString & "'" & Trim(OperationalStaff) & "',"
sqlString = sqlString & "'" & Trim(ExecutiveStaff) & "',"
sqlString = sqlString & "'" & Trim(EmergencyCertifiedPer
sqlString = sqlString & "'" & Trim(VendorSupport) & "',"
sqlString = sqlString & "'" & Trim(EPLO) & "'"
Dim myTable As CrystalDecisions.CrystalRe
Dim myLogin As CrystalDecisions.Shared.Ta
For Each myTable In crCTCPhoneListing.Database
myLogin = myTable.LogOnInfo
myLogin.ConnectionInfo.Pas
myLogin.ConnectionInfo.Use
myTable.ApplyLogOnInfo(myL
Next
Dim da As SqlDataAdapter
da = New SqlDataAdapter(sqlString, objConnection)
Dim ds As New DataSet
da.Fill(ds, "CTCPhoneList")
crCTCPhoneListing.SetDataS
'CleanUp
objConnection.Close()
objConnection = Nothing
crCTCPhoneListing.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = String.Format("application
Response.WriteFile(tempFil
Response.Flush()
Response.Close()
'System.IO.File.Delete(tem
End Function
--------------------------
If you see my above code, i am getting connection information from web.config file.
no hard coding inside my web page.
--------------------------
Hope it helps. Good Luck.
ASKER
I am not using ASP.NET. No web config files here. I am using vb.net. I did try the methods outlined and I am able to login to my dev server fine but moving to any other server retiurns "Unable to open rowset". I know the connection is valid because other parts of the app that use an ADO.net OLEDB are fine.
Is there any way of knowing what the error might be?
Is there any way of knowing what the error might be?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad i could help
mlmcc
mlmcc
ASKER