日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

取消水晶报表的数据库登录框 分享

發(fā)布時間:2023/11/27 生活经验 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 取消水晶报表的数据库登录框 分享 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?

?

????? 這兩天在和斌做后臺中的報表,暫定使用水晶報表,目前還只是處于對水晶報表的初級應(yīng)用階段,也就是知道如何 匯個總、寫個函數(shù)、傳個參數(shù)。

?

?

????? 問題總是層出不窮,在最后整合報表,進行報表顯示測試的時候,發(fā)現(xiàn)每次更新數(shù)據(jù)顯示(除第一次)時都會蹦出一個“登錄數(shù)據(jù)庫的信息提示界面”很是苦悶,并且這肯定不是我們需要的,還是需要花大力氣搞定的。

?

?

???? 于是參考了某斑竹寫的一篇 “取消水晶報表的數(shù)據(jù)庫登陸框”博文。頗有感觸,于是進行了消化吸收,整合代碼如下。

?

?

???? 主要是,針對水晶報表對每數(shù)據(jù)庫登錄(DbLogOn)提供一次數(shù)據(jù)庫鏈接信息。

?

?

Imports CrystalDecisions.Shared Imports CrystalDecisions.CrystalReports.Engine Imports System.Reflection Imports System.Configuration Imports CrystalDecisions.Web Public Class ReportConfig ''' <summary> ''' 提供web報表鏈接數(shù)據(jù)庫所需要的信息,無參數(shù),有返回值。 ''' </summary> ''' <returns>返回鏈接信息的屬性,其中有servername、database、userid、pwd</returns> ''' <remarks></remarks> Public Function readConfig() As TableLogOnInfo Dim strServerName As String Dim strDataBase As String Dim strUserId As String Dim strPwd As String Dim logoninfo As New TableLogOnInfo '從web.config配置文件中讀取信息. strServerName = System.Configuration.ConfigurationManager.AppSettings("servername") strDataBase = System.Configuration.ConfigurationManager.AppSettings("database") strUserId = System.Configuration.ConfigurationManager.AppSettings("userid") strPwd = System.Configuration.ConfigurationManager.AppSettings("pwd") logoninfo.ConnectionInfo.ServerName = strServerName logoninfo.ConnectionInfo.DatabaseName = strDataBase logoninfo.ConnectionInfo.UserID = strUserId logoninfo.ConnectionInfo.Password = strPwd '信息封裝成logoninfo. Return logoninfo End Function ''' <summary> ''' 設(shè)置報表查看器不再顯示登錄數(shù)據(jù)庫提示 ''' </summary> ''' <param name="crv">當前報表查看器id</param> ''' <param name="coninfo">報表鏈接到數(shù)據(jù)庫所需信息</param> ''' <returns></returns> ''' <remarks></remarks> Public Function SetDbLoginForReport(ByVal crv As CrystalReportViewer, ByVal coninfo As ConnectionInfo) As String 'tablelogoninfos 就是包括每個表中的logoninfo對象 Dim tablelogoninfos As TableLogOnInfos = crv.LogOnInfo Dim logoninfo As New TableLogOnInfo For Each logoninfo In tablelogoninfos '綁定每一個logoninfo對象的數(shù)據(jù)庫鏈接信息,這樣可以不再顯示數(shù)據(jù)庫登錄提示信息。 logoninfo.ConnectionInfo = coninfo Next Return Nothing End Function End Class

?

?

中一個報表:

?

? '省略.... Dim SelectByDate As New CollectMgr Dim dt As New DataTable Dim doc As New ReportDocument Dim coninfo As New TableLogOnInfo Dim reportconfig As New ReportConfig '省略.... '獲得報表鏈接數(shù)據(jù)庫所需的所有參數(shù)信息 coninfo = reportconfig.readConfig Try '加載報表樣表 doc.Load(Server.MapPath("./Cashier.rpt")) '返回數(shù)據(jù)源 If txtStartTime.Value = txtEndTime.Value Then dt = SelectByDate.FoodCollect(txtStartTime.Value) Else dt = SelectByDate.FoodCollect(txtStartTime.Value, txtEndTime.Value) End If doc.SetDataSource(dt) crvCashierReport.ReportSource = doc '防止出現(xiàn)提示登錄數(shù)據(jù)庫的情況 reportconfig.SetDbLoginForReport(crvCashierReport, coninfo.ConnectionInfo) '結(jié)束

?

?

?

置文件:

<appSettings> <add key="servername" value="****" /> <add key="database" value="***" /> <add key="userid" value="**" /> <add key="pwd" value="***" /> </appSettings>

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/lfsfxy9/archive/2010/06/07/2629370.html

總結(jié)

以上是生活随笔為你收集整理的取消水晶报表的数据库登录框 分享的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。