.NETGURU
connecting to db for a report view
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-crystal' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Greg Bernhardt
I am so lost how to connect to my db for a report. something about a
logOnInfo and ConnectionInfo. Can someone help me out? Thanks

Reply to this message...
 
    
Eric Landes (VIP)
Not sure if you've solved this Greg, but here how I connect using a =
stored
procedure (should also work with straight tables). Also this shows =
using
parameters (in VB.NET): =20

--- Begin code --
Dim oReport As New
CrystalDecisions.CrystalReports.Engine.ReportDocument()
oReport.Load("C:\wwwroot\CrystalDotNetConversion\Sales By =
Year.rpt",
CrystalDecisions.[Shared].OpenReportMethod.OpenReportByTempCopy)
Dim oCRDb As CrystalDecisions.CrystalReports.Engine.Database =3D
oReport.Database
Dim oCRTables As CrystalDecisions.CrystalReports.Engine.Tables =
=3D
oCRDb.Tables
Dim oCRTable As CrystalDecisions.CrystalReports.Engine.Table
Dim oCRTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
Dim oCRConnectionInfo As New
CrystalDecisions.Shared.ConnectionInfo()
' Dim oCRBeginDateParam As
CrystalDecisions.Shared.ParameterField
Dim oCREndDateParam As CrystalDecisions.Shared.ParameterField
oCRConnectionInfo.DatabaseName =3D "Northwind"
oCRConnectionInfo.ServerName =3D "(local)"
oCRConnectionInfo.UserID =3D "guest"
oCRConnectionInfo.Password =3D ""
For Each oCRTable In oCRTables
oCRTableLogonInfo =3D oCRTable.LogOnInfo
oCRTableLogonInfo.ConnectionInfo =3D oCRConnectionInfo
oCRTable.ApplyLogOnInfo(oCRTableLogonInfo)

Next

CrystalReportViewer1.ReportSource =3D oReport

Dim oCRParamField As CrystalDecisions.Shared.ParameterField
Dim oCRParamField2 As CrystalDecisions.Shared.ParameterField
Dim oCrParamFields As CrystalDecisions.Shared.ParameterFields
Dim oCrDiscreteParam As
CrystalDecisions.Shared.ParameterDiscreteValue
Dim oCrDiscreteParam2 As
CrystalDecisions.Shared.ParameterDiscreteValue
Dim ocrParamValues As CrystalDecisions.Shared.ParameterValues
Dim ocrParamValues2 As CrystalDecisions.Shared.ParameterValues
oCrParamFields =3D CrystalReportViewer1.ParameterFieldInfo
oCRParamField =3D oCrParamFields.Item("@Beginning_Date")
ocrParamValues =3D oCRParamField.CurrentValues
oCrDiscreteParam =3D New
CrystalDecisions.Shared.ParameterDiscreteValue()
oCrDiscreteParam.Value =3D CDate("1/1/1998")
ocrParamValues.Add(oCrDiscreteParam)
oCRParamField2 =3D oCrParamFields.Item("@Ending_Date")
oCrDiscreteParam =3D Nothing
ocrParamValues2 =3D oCRParamField2.CurrentValues
oCrDiscreteParam2 =3D New
CrystalDecisions.Shared.ParameterDiscreteValue()
oCrDiscreteParam2.Value =3D CDate("12/31/2002")
ocrParamValues2.Add(oCrDiscreteParam2)

''Set the modified parameters collection back to the viewer so =
that
''the new parameter information can be used for the report.
CrystalReportViewer1.ParameterFieldInfo =3D oCrParamFields

CrystalReportViewer1.DataBind()

--- End code --

HTH

*************************=20
Eric Landes=20
Senior Programmer/Analyst (Partners Health Plan) and member of the
ASPFriends.com Moderator team=20
For Articles on Crystal.Net, Datagrids and more check out
http://www.aspalliance.com/corporatecoder/
*************************=20
All statements expressed are my own, and do not reflect the opinion of =
my
employer, unless stated otherwise.=20

-----Original Message-----
From: Greg Bernhardt [mailto:Click here to reveal e-mail address]
Sent: Wednesday, August 14, 2002 5:00 PM
To: ngfx-crystal
Subject: [ngfx-crystal] connecting to db for a report view

I am so lost how to connect to my db for a report. something about a
logOnInfo and ConnectionInfo. Can someone help me out? Thanks

Confidentiality Notice: This e-mail message, including any
attachments, is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not
the intended recipient, please contact the sender by reply e-mail and
destroy all copies of the original message.

PARTNERS Health Plan Phone: 574-233-4899
100 E. Wayne St., Suite 502 Fax: 574-234-7484
South Bend, IN 46601 www.partnersindiana.com

Reply to this message...
 
    
Rod G
I do something similiar for my Crystal Report used with my .NET applicaiton.
I use the

CrystalDecisions.Shared.ConnectionInfo() object

I loop through the tables and use the ConnectionInfo databasename, servername, userid, and password and use the ApplyLogOnInfo method.

My report works fine. However, our DBA is telling me that my app is holding the dataconnection and messing up some of her nightly jobs.

After I refresh my crystal report with the following code

CrystalReportViewer2.RefreshReport()

How do I close my database connection?

I do not see a Close() method for the ConnectionInfo() object.

Thanks,
Rod
--------------------------------
Reply to this message...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification