Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic connection in crystal report

Status
Not open for further replies.

mohanmsc

Programmer
Jul 26, 2005
6
0
0
IN
hi guys

I developed an web application in asp.net and i am generating reports using crystal report. what my problem is i place the field values in design time only, so my connection information are also selected in design time. if the report is deploy to online server. how i give the connection information in design time..

i want the connection information dynamically (i.e doing in code behind side)..




thanks lot


 
This is an example of using the push method and a SQL SP.


Dim crReport As New YourReportName()

Page Load..

Dim cn As SqlConnection = New SqlConnection()
Dim dsReport As New DataSet()

Set your connection string..

for help with strings go to
Dim cmd As New SqlCommand()

With cmd
.Connection = cn
.CommandType = CommandType.StoredProcedure
.CommandText = "YourSP"
End With

Dim DA As New SqlDataAdapter(cmd)

cn.Open()

Dim crDatabase As CrystalDecisions.CrystalReports.Engine.Database
Dim crTables As CrystalDecisions.CrystalReports.Engine.Tables
Dim crTable As CrystalDecisions.CrystalReports.Engine.Table

DA.Fill(YourDataSetName, "YourSP")

crDatabase = crReportDoc.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crTable.SetDataSource(YourDataSetName)
Next

YourReportName.ReportSource = crReport

cn.Close()


There are tons of examples on the web...search around you will find them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top