Вы находитесь на странице: 1из 22

http:// www.DSICT.

com
dsict.com

VS.NET
NameSpace

$
#

SQL Server

Login

SQL Server
Connect #

SQL Server

+ ,

-.*

"

& )

"

!
# & $'()

1!

0 -.*
"-

:;

$/)

23

4 /5

85 # & 95

1! 6 - . *

string reportPath = Server.MapPath("Report .rpt ");

Application.StartupPath

5 # & 95

"-

"string RepPath=Application.StartupPath + @"\Report\Report .rpt";

<
*

= >#?

G 6

Viewer

1! 6
4

@AB #

1! F

< #

<C% D 4
G=

"
$ /)

5 5 5 85 # & 95 #
"

-.*

crystalReportViewer.ReportSource

crystalReportViewer.ReportSource = RepPath;

H E5

"$ )

-&

KE Connection
"

ConnectionInfo

.*
4

$ 6 EF
3J>

ConnectionInfo

- . * UserID,DataBaseName,Password
7

ConnectionInfo connectionInfo = new ConnectionInfo();


connectionInfo.ServerName = "DynamicMethods";
connectionInfo.DatabaseName = "Db ";
connectionInfo.UserID = "sa";
";
connectionInfo.Password = "

http:// www.DSICT.com
dsict.com

H *

crystalReportViewer

< #

ConnectionInfo

G=

"7

private void SetLogin(ConnectionInfo connectionInfo)


{
TableLogOnInfos TbLogOnInfos = crystalReportViewer.LogOnInfo;
foreach (TableLogOnInfo TbLogOnInfos in TbLogOnInfos)
{
TbLogOnInfos.ConnectionInfo = connectionInfo;
}
}

7-

C#

; 5 5 95 L #

ConnectionInfo connectionInfo = new ConnectionInfo();


connectionInfo.ServerName = "DynamicMethods";
connectionInfo.DatabaseName = "Db ";
connectionInfo.UserID = "sa";
";
connectionInfo.Password = "
string RepPath=Application.StartupPath + @"\Report\Report .rpt";
crystalReportViewer.ReportSource = RepPath;
SetLogin(connectionInfo);
---------------------------------------------------------------------private void SetLogin(ConnectionInfo connectionInfo)
{
TableLogOnInfos TbLogOnInfos = crystalReportViewer.LogOnInfo;
foreach (TableLogOnInfo TbLogOnInfos in TbLogOnInfos)
{
TbLogOnInfos.ConnectionInfo = connectionInfo;
}
}

" &
7-

C#

E Page_Load

D 4

;85 95 L #

ConnectionInfo connectionInfo = new ConnectionInfo();


connectionInfo.ServerName = "DynamicMethods";
connectionInfo.DatabaseName = "Db ";
connectionInfo.UserID = "sa";
";
connectionInfo.Password = "
string reportPath = Server.MapPath("Report .rpt");
crystalReportViewer.ReportSource = RepPath;
SetLogin(connectionInfo);
---------------------------------------------------------------------private void SetLogin(ConnectionInfo connectionInfo)
{
TableLogOnInfos TbLogOnInfos = crystalReportViewer.LogOnInfo;
foreach (TableLogOnInfo TbLogOnInfos in TbLogOnInfos)
{
TbLogOnInfos.ConnectionInfo = connectionInfo;
}
}

" &

E Page_Init

D 4

http:// www.DSICT.com
dsict.com

SQL Authentication '


"

& )O

1! SQL Server

G5 Q L

"

SQL Server

-& )

) G5 Q T #
"

2N 6

$ 6E F

ReportDocument P

SQL Server '

ConnectionInfo

7-

23

Login

. F #

RS L -

$/)

2(

RS F G

4 / ReportDocument P U V* #

ReportDocument RepDoc=new ReportDocument();

"-

23

:;

4 /5

85 # & 95

1! 6 - . * #

string reportPath = Server.MapPath("Report .rpt");

Application.StartupPath

5 # & 95

"-

"string RepPath=Application.StartupPath + @"\Report\Report .rpt";

<
*

= >#?

G 6

Viewer

1! 6
4

@AB #

1! F

# ReportDocument P

< #
F #

< 4

G=

"
"-

RepDoc.Load(RepPath);

"- &

<C% D 4

G 6

ReportDocument P G =

Viewer

crystalReportViewer.ReportSource = RepDoc;

H *

R X * 'KE $ 6E

ConnectionInfo

"-

4 .*G 3

SetLogin

private void SetLogin(ConnectionInfo connectionInfo,ReportDocument reportdocument)

{
Tables tables = reportdocument.Database.Tables;

http:// www.DSICT.com
dsict.com
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo TbLogonInfo = table.LogOnInfo;
TbLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(TbLogonInfo);
}
}

7-

C#

; 5 5 95 L #

ConnectionInfo connectionInfo = new ConnectionInfo();


ReportDocument RepDoc=new ReportDocument();
connectionInfo.ServerName = "DynamicMethods";
connectionInfo.DatabaseName = "Db ";
connectionInfo.UserID = "sa";
connectionInfo.Password = "
";
string RepPath=Application.StartupPath + @"\Report\Report .rpt";
RepDoc.Load(RepPath);
crystalReportViewer.ReportSource = RepDoc;
SetLogin(connectionInfo, RepDoc);
---------------------------------------------------------------------private void SetLogin(ConnectionInfo connectionInfo,ReportDocument

reportdocument)
{
Tables tables = reportdocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in
tables)
{
TableLogOnInfo TbLogonInfo = table.LogOnInfo;
TbLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(TbLogonInfo);
}
}

7-

C#

;85 95 L #

ConnectionInfo connectionInfo = new ConnectionInfo();


ReportDocument RepDoc=new ReportDocument();
connectionInfo.ServerName = "DynamicMethods";
connectionInfo.DatabaseName = "Db ";
connectionInfo.UserID = "sa";
connectionInfo.Password = "
";
string reportPath = Server.MapPath("Report .rpt");
RepDoc.Load(RepPath);
crystalReportViewer.ReportSource = RepDoc;
SetLogin(connectionInfo, RepDoc);
---------------------------------------------------------------------private void SetLogin(ConnectionInfo connectionInfo,ReportDocument

reportdocument)
{
Tables tables = reportdocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in
tables)
{
TableLogOnInfo TbLogonInfo = table.LogOnInfo;
TbLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(TbLogonInfo);

http:// www.DSICT.com
dsict.com
}
}

&
2 3

4 Y
":$

6 VS.NET '
RKX * 'KE # & Z
% VS.NET '

4
T
4

G 6

#&

&

' 4 /
G 6

#&

K[ ;
C G

"
ReportDocument RepDoc = new ReportDocument();
string RepPath = Application.StartupPath + "\\CrystalReport .rpt";
RepDoc.Load(RepPath);
crystalReportViewer .ReportSource = RepDoc;
//------------------------------------------ParameterValues parameterValues = new ParameterValues();
ParameterDiscreteValue parameterDiscreteValue = new
ParameterDiscreteValue();
parameterDiscreteValue.Value = "ParameterValue";
parameterValues.Add(parameterDiscreteValue);
ParameterFieldDefinitions parameterFieldDefinitions =
RepDoc.DataDefinition.ParameterFields;
ParameterFieldDefinition parameterFieldDefinition =
parameterFieldDefinitions["ParameterName"];
parameterFieldDefinition.ApplyCurrentValues(parameterValues);

http:// www.DSICT.com
dsict.com

Selection Formula '


Z 1!

& )

G \ #
:

"

Z 1!

^ ) 5

3X# B

` W Selection Formula < *

L #

; X# B

F 5

"

&

5
4

1! B
)#&

Z 1!

. F

D Z 1! $) #

ReportDocument RepDoc = new ReportDocument();


string RepPath = Application.StartupPath + "\\CrystalReport .rpt";
RepDoc.Load(RepPath);
string SFormula= "{Customer.Code}=
";
RepDoc.DataDefinition.RecordSelectionFormula = SFormula;
crystalReportViewer .ReportSource = RepDoc;

String a

# B

! G=

ReportDocument RepDoc = new ReportDocument();


string RepPath = Application.StartupPath + "\\CrystalReport .rpt";
RepDoc.Load(RepPath);
string SFormula= "{Customer.Code}='
'";
RepDoc.DataDefinition.RecordSelectionFormula = SFormula;
crystalReportViewer .ReportSource = RepDoc;

G 6

Select Expert

" 0

#&
[ *#&

G
&

#
5

http:// www.DSICT.com
dsict.com

& SubReport
O HE
* c

bV

Connect

= > Crystal Report < *


4

1!
"

, , [5"
2( DataBase

1! B

& SubReport

2=
-.*

T
Q

SubReport

" & `W
"

0 #

ConnectionInfo "_

ConnectionInfo connectionInfo = new ConnectionInfo();


connectionInfo.ServerName = ".";
connectionInfo.DatabaseName = "anbar";
connectionInfo.UserID = "sa";
connectionInfo.Password = "
";

@AB

Z 1! 6 "

ReportDocument RepDoc = new ReportDocument();


string RepPath = Application.StartupPath + "\\CrystalReport .rpt";
RepDoc.Load(RepPath);

-6

Login H * L

'/ Report #

"d

private void SetLoginMainReport(ConnectionInfo connectionInfo,


ReportDocument reportdocument)
{
Tables tables = reportdocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table
in tables)
{
TableLogOnInfo TbLogonInfo = table.LogOnInfo;
TbLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(TbLogonInfo);

http:// www.DSICT.com
dsict.com
}
}

"- &

` W SubReport #

F & G = "e

private void SetLoginSubReport(ConnectionInfo connectionInfo,


ReportDocument reportdocument)
{
Sections sections = reportdocument.ReportDefinition.Sections;

foreach (Section section in sections)


{
ReportObjects RepObjs = section.ReportObjects;
foreach (ReportObject RepObj in RepObjs)
{
if (RepObj.Kind ==ReportObjectKind.SubreportObject)

{
SubreportObject SubreportObj = (SubreportObject)RepObj;

ReportDocument SubReportDoc =
SubreportObj.OpenSubreport(SubreportObj.SubreportName);
SetLoginMainReport(connectionInfo, SubReportDoc);

}
}
}
}

4 / 2

) %F -

) %

H *5 G= "
"$

ConnectionInfo connectionInfo = new ConnectionInfo();


connectionInfo.ServerName = ".";
connectionInfo.DatabaseName = "anbar";
connectionInfo.UserID = "sa";
connectionInfo.Password = "
";
ReportDocument RepDoc = new ReportDocument();
string RepPath = Application.StartupPath + "\\CrystalReport .rpt";
RepDoc.Load(RepPath);
SetLoginMainReport(connectionInfo, RepDoc);
SetLoginSubReport(connectionInfo,RepDoc);
crystalReportViewer .ReportSource=RepDoc;

http:// www.DSICT.com
dsict.com

DataSet Z 1! G (*
< *

2( DataBase
#

& )

T DataSet

C6 4

1!

1! G (*

1!
Q *"

"
!

"
0 #

& ) ` W DataSet Schema


` W Schema < *

1! 5

F 5

DataSet P

$) - & ) DataSet Schema a

Add Connection

, $ 6E F

L' $

& 95

Connection L a5

Server Explorer #5
"

8A

#
"_

http:// www.DSICT.com
dsict.com

" & `W

1! Add #
58A

5
DataSet

L'

8A

>

` %

4 . * Mc "

95 #5

Solution Explorer

5 5 # & 95 #
"

>

58A

XML Schema

G = "d

New Item

85 # & f5 #

http:// www.DSICT.com
dsict.com

#5

8A

>

G5 Q Solution Explore $ 6E
"

1! Add #

5
"

8A

"$) - & ) Schema '

L'

Solution Explorer

Crystal Report

>

` %

1! Wizard

&

Dataset .xsd

95 #5
58A

G = "e

G= "

New Item

20

& "g

http:// www.DSICT.com
dsict.com

Available Data $ 6E

Standard Report Creation Wizard ` %


]

tree 4 /

"h

Source

Project Data-> ADO.NET DataSet -> YourDataSetName-> Your Table Name

"

2=

"

&B

&B 1

>

` %

(*

# V #&` % *
"

&B

L ' Next #5
)

Finish

"i

http:// www.DSICT.com
dsict.com

"

95

>

Mc

"j

string ConStr = "Data Source=.;Initial Catalog=Anbar;User


ID=sa;Password=
";
SqlConnection SQLCon = new SqlConnection(ConStr);
SqlDataAdapter SQLAdapter = new SqlDataAdapter("SELECT * FROM
TbPersonal", SQLCon);
DataSet dataset = new DataSet ();
SQLAdapter.Fill(dataset, "TbPersonal");
//-----------------------------------------------ConnectionInfo connectionInfo = new ConnectionInfo();
ReportDocument RepDoc = new ReportDocument();
connectionInfo.ServerName = ".";
connectionInfo.DatabaseName = "anbar";
connectionInfo.UserID = "sa";
connectionInfo.Password = "
";
string RepPath = Application.StartupPath + @"\CrystalReport .rpt";
RepDoc.Load(RepPath);
RepDoc.SetDataSource(dataset);
crystalReportViewer .ReportSource = RepDoc;

http:// www.DSICT.com
dsict.com

IDataReader Z 1! G (*
!

k*

DataReader P

) DataReader P
F

S &"

"

:
. F #

Windows a
`5 95

Mc "

.NET # & 95
DataSet

Interface L

W 95
Class Libarary a
" 6

B k*

T $3

) IDataReader; IDataReader

Multi Tier 6

G5 95

5
`5 95

Calss_.cs #

private const string ConStr = "Data Source=.;Initial


Catalog=Anbar;User ID=sa;Password=
";
public static IDataReader GetTbPersonal()
{

-& )

$ 6E

) Solution

Explorer

5 Application
:Class Libarary;

http:// www.DSICT.com
dsict.com
SqlConnection SQLCon = new SqlConnection(ConStr);
SQLCon.Open();
SqlCommand SQLCommand = new SqlCommand("SELECT * FROM
TbPersonal", SQLCon);
IDataReader iDataR = SQLCommand.ExecuteReader();
return iDataR;
}

Build
"$

1! 5
)

L ' :Class Libarary; `5 95

DLL L
":

Crystal - T L 5

Build #
V;
$

&B "

c6 > ) Output

Available Data $ 6 E

Q Connection F )

"_

8A
DLL 6

L ' :Application; G5 95
"

"$) - & )

#5

8A

Z 1! Wizard

#5

"

Report
20

& "d

Standard Report Creation Wizard ` %

Node ]

tree 4 /
"

Create New Connection -> ADO.NET

Source

8A

"e

http:// www.DSICT.com
dsict.com

"

"

23

8A

DLL 2 % ADO.NET ` %

(*

&5

G= "

L ' Finish ' #5

"g

http:// www.DSICT.com
dsict.com

& '%4 / ,
"$

&B

20

"h

l A

Class

SqlCommand SQLCommand = new SqlCommand("SELECT * FROM TbPersonal", SQLCon);

+ , G = :ALL

V m; $

Q A

#& '%

V*

D <) HE 5
4 /

SqlCommand SQLCommand = new SqlCommand("SELECT ID,Name FROM TbPersonal", SQLCon);

" &

1! * 6

:Application; G5 95

ID,Name ' % 5 <C%

G = "i
"

string RepPath = Application.StartupPath + "\\CrystalReport .rpt";


ReportDocument RepDoc = new ReportDocument();
RepDoc.Load(RepPath);
crystalReportViewer .ReportSource = RepDoc;

http:// www.DSICT.com
dsict.com

'"

( )*

! "#

$%

&
"

Crystal Reports # & Merge Module


CR
#5
bV

G = "-

+ ,
CR

?* Setup

#5

& )

A6 # & Merge Module

Q * "CR U' A # & A6 # & Merge Module $

-& )

http:// www.DSICT.com
dsict.com

)$

bV 5

k( L *

* 4 / Merge Module
"

$%

Business Object

Crystal Reports jn

"_

Crystal Reports _ n

"

Crystal Reports __n

"d

http:// www.DSICT.com
dsict.com

CR For VS.NET

CR For VS.NET

"e

d "

http:// www.DSICT.com
dsict.com

VQ

o T

B 4 3J> k6 #

http://support.businessobjects.com/downloads/merge_modules.asp

#5

Crystal Reports Developer Edtion


p q=K

0 F

A[ 4
#

1! = > q :$6& D -

&#

$!

0%;

[5

7
"$

1&

F s 6 t 1 # & 1% `

r [

5 $6

<C%; $6

Z 1! # &

-& %

A[ #

*
#

TZ

T "_

1! s 6

& "

": 6& 0
"$
"

E5 T #
D

% "d

95 $ E "e
""" 5 "

"
5

k Q

Crystal Reports XI Developer Edition R

"
T # & Merge Module 5

?*
E

T A6 F )T

A6
A6 F

1 .NET #
7

% V A6
* K3 .NET #

CrystalReports___maps.msm
CrystalReports___RDC_Designtime.msm
CrystalReports___RDC_License.msm
CrystalReports___RDC_Reportengine.msm
CrystalReports___RDC_Runtime.msm

" BZ

%D 40

` 5

http:// www.DSICT.com
dsict.com

Doc % &' !
3,

! )*
. /&-

&

! " #$
!

01

Doc % +

&

Вам также может понравиться