Private Sub frmReportExpenses_Load(ByVal sender As Object,ByVal e As System.EventArgs)处理Me.Load
Dim objDatasetExpence As New dSetExpences // dataset object named as dSetExpences
Dim objRptExpence As New rptExpences // Crystal report object
Dim MyCommand As New OleDbCommand()
Dim MyConnection As OleDbConnection
Dim myDA As New OleDbDataAdapter()
Try
Dim connstring As String = "D:\HMSProjects\SMS\SMS\bin\Debug\"
MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + connstring + "msautoconfig.mdb;")
MyConnection.Open()
MyCommand.Connection = MyConnection
MyCommand.CommandText = "SELECT * FROM expences"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(objDatasetExpence, "expences")
objRptExpence.SetDataSource(objDatasetExpence)
CrystalReportViewer1.ReportSource = objRptExpence
Catch ex As Exception
End Try
Me.WindowState = FormWindowState.Maximized
End Sub
结束班
上面的代码有什么不对,它不起作用。我想用实际的Access 2003数据库显示水晶报告。在项目中添加空白报告并尝试填充DataSet对象,以上代码中的任何建议或更正。它是一个Windows窗体应用程序