Title: Visual Basic 2005?????
1CH10
2????
3????
??????
?????????????????,?VB6.0??,???????Crystal
Report????,?Visual Studio?????????Crystal
Report????????????,SQL Server?Reporting
Services,????????????????????
???????,Visual Studio 2005??????????,????????????(
.rdlc)?,?????????????????????????????????,????????
????????? ?Crystal Report??,?????????Visu
al Basic Express????,?????Visual Studio
2005????????????
4????
?????????
5????
????????
6????
????????
??????????????.rdlc???????
7????
??????
?????????????,?????????????????
8????
??????
9????
??????
Visual Studio 2005???????????????,????????
10????
??????
????????,???????????????cNorthWind.Mdf??????????(T
able)?????(View)
?????????,????????
11????
??????
????,Visual Studio 2005????????????.xsd??
?????????????
12????
??????
???????????Report1.rdlc??,???????????
?????????????????????????
13????
??????
???????????Report1.rdlc??,???????????
???????TextBox ????,???,??TextBox?????????????Text
Box????,??????TextBox???????TtextBox???
14????
??????
??????,????TextBox????????,??????
15????
??????
??,??????????????,???????????????????????Table???
16????
??????
Table?????Row,???????????,?????????,??????????????
?????????,?????????,???????,???????????????????
????
??????
????
17????
??????
????????????????????,???????????????????
????????????
18????
??????
????????Table????,?????,?????Column?,????????
19????
??????
??????????????????
20????
??????
???Table??????????,????????RepeatOnNewPage??True
???Table???????????
???????RepeatOnNewPage??True,?????????,???????????
?
21????
??????????
???????????????,???????????,???????ReportViewer???
????
???????ReportViewer???????
??SmartTag????????????????????Report1
22????
??????????
????,?????????????,?????????????????
23????
???????????
?????????,???????????????,????????????????,???????
?,????????,?????????(?????Report_Parameter_0)
??????????????
??????,??????????
24????
???????????
???????????????,??????TextBox????
25????
???????????
????????TextBox?Value??
26????
???????????
?????????,????????????????,?????????,????????????T
extBox?
27????
???????????
?????????????,????Form1_Load???,?????Form1?Load???
?,?????Visual Studio 2005???????????
EX CH10\ReportDemo\Form1.vb
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO ??????????? 'cNorthWindDataSet.???' ?????????????????? Me.???TableAdapter.Fill(Me.cNorthWindDataSet.???) Me.ReportViewer1.RefreshReport() End Sub
28????
???????????
????
EXCH10\ReportDemo\Form1.vb
0000 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 0001 'TODO ??????????? 'cNorthWindDataSet.???' ?????????????????? 0002 Me.???TableAdapter.Fill(Me.cNorthWindDataSet.???) 0003 0004 '??????(???? 0-1) 0005 Dim paras(1) As Microsoft.Reporting.WinForms.ReportParameter 0006 '??????????? 0007 paras(0) New Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_UserName", "???David") 0008 paras(1) New Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CreateDT", "????" Now.ToString) 0009 '??SetParemeters???????? 0010 Me.ReportViewer1.LocalReport.SetParameters(paras) 0011 Me.ReportViewer1.RefreshReport() 0012 End Sub
???,????,??????????????????????
29????
???????????
?????TextBox??,????????,???????????????????????
????????,???????????
30????
????????
?????,??????TextBox???Button
??SQL???????????
31????
????????
??????Click????,????????,1-7??????????????
EXCH10\ReportDemo\Form1.vb
0000 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 0001 '??????(???? 0-1) 0002 Dim paras(1) As Microsoft.Reporting.WinForms.ReportParameter 0003 '??????????? 0004 paras(0) New Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_UserName", "???David") 0005 paras(1) New Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CreateDT", "????" Now.ToString) 0006 '??SetParemeters???????? 0007 Me.ReportViewer1.LocalReport.SetParameters(paras) 0008 0009 '?????? 0010 Dim db As New DbAccess("cNorthWind.MDF") 0011 Dim dt As DataTable db.GetDataTable(Me.txb_SQL.Text) 0012 '?????????????,?????? 0013 Me.ReportViewer1.LocalReport.DataSources(0).Value dt 0014 Me.ReportViewer1.RefreshReport() 0015 End Sub
32????
????????
??????Click????,????????,1-7??????????????
EXCH10\ReportDemo\Form1.vb
0000 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click (?) 0009 '?????? 0010 Dim db As New DbAccess("cNorthWind.MDF") 0011 Dim dt As DataTable db.GetDataTable(Me.txb_SQL.Text) 0012 '?????????????,?????? 0013 Me.ReportViewer1.LocalReport.DataSources(0).Value dt 0014 Me.ReportViewer1.RefreshReport() 0015 End Sub
???????????DbAccess???????,??11????????Tex
tBox???SQL???????,???????DataTable????,????????dt?
??? ???dt(DataTable)??ReportViewer????????
??(?13?),???14??????????
33????
????????
???????????????????
??????????????(??????????)