熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

快速學習.net制作水晶報表

2022-06-13   來源: .NET編程 
net制作水晶報表分以下個步驟

  新建一個windows applicationCristalTest;

  新添加一個數據集DataSetxsd 

  在DataSet裡添加表DataTable 

  在DataTable裡添加四列ColumnColumnColumnColumn 保存

  添加一個水晶報表文件CrystalReportrpt 

  設置數據源項目數據(Project Data)>Adonet DataSets>***DataSet>DataTable 

  把ColumnColumnColumnColumn拖到水晶報表的細節(Details)中 

  添加一個控件CrystalReportViewer到Form中 

  然後添加Form_Load的代碼 

  Dim m_sqlConn As SqlConnection
  Dim m_strSqlConn As String
  m_strSqlConn = Data Source=localhost; initial catalog=pubs;User id=sa;password=
  m_sqlConn = New SqlConnection(m_strSqlConn)
  Try
  Dim sqlAdp As SqlDataAdapter
  Dim strSql As String
  Dim ds = New DataSet()
  m_sqlConnOpen()
  strSql = SELECT au_lname AS Column au_fname AS Column phone AS Column address AS Column FROM dboauthors
  sqlAdp = New SqlDataAdapter(strSql m_sqlConn)
  sqlAdpFill(ds)

  Dim crReportDocument = New CrystalReport()
  crReportDocumentSetDataSource(dsTables())
  CrystalReportViewerReportSource = crReportDocument
  Catch ex As Exception
  MessageBoxShow(exToString())
  End Try 

  在formvb文件頭加 

  Imports SystemData
  Imports SystemDataSqlClient 

   m_strSqlConn = Data Source=localhost; initial catalog=pubs;User id=sa;password=這個可能要修改成你的機器的Sql Server連接信息


From:http://tw.wingwit.com/Article/program/net/201311/15804.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.