日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

VS2010 水晶報(bào)表的使用方法_.Net教程

編輯Tag賺U幣
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!

推薦:ASP.NET中操作SQL數(shù)據(jù)庫(kù)(連接字符串的配置及獲取)
在WebConfig中配置數(shù)據(jù)庫(kù)連接字符串,代碼如下: 復(fù)制代碼 代碼如下: connectionStrings add name=ConnectionString connectionString=user id=用戶名;password=密碼;initial catalog=數(shù)據(jù)庫(kù)名稱;data source=服務(wù)器名稱/ /connectionStrings 然后在Webform_1.aspx.cs

在VS2010中新建一個(gè)“Windows 窗體應(yīng)用程序”項(xiàng)目,在該項(xiàng)目中添加一個(gè)水晶報(bào)表“CrystalReport1.rpt”,然后在項(xiàng)目上點(diǎn)擊鼠標(biāo)右鍵屬性,將“目標(biāo)框架”改為“.Net Framework 4”

2013-06-20_003334
 

打開(kāi)app.config文件,在“startup”節(jié)點(diǎn)一個(gè)“useLegacyV2RuntimeActivationPolicy="true"”屬性

復(fù)制代碼 代碼如下:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>

在Form1窗體中,從工具箱拖出一個(gè)Crystal Report Viewer控件,雙擊Form窗體,是雙擊Form窗體,不是Crystal Report Viewer,在后臺(tái)的Form_Load事件中寫(xiě)入如下代碼:

復(fù)制代碼 代碼如下:
private void Form1_Load(object sender, EventArgs e)
{
string connStr = "Data Source=.\SqlExpress;Initial Catalog=dbTest;User ID=sa;Password=test";
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
try
{
string sql = "SELECT * FROM Customer where email!='[email protected]'";
SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
sda.Fill(ds, "tmpTable");

string reportPath = System.Windows.Forms.Application.StartupPath + @"CrystalReport1.rpt";
ReportDocument rd = new ReportDocument();
rd.Load(reportPath);
rd.SetDataSource(ds.Tables[0].DefaultView);
this.crystalReportViewer1.ReportSource = rd;
}
catch (Exception ex)
{
throw new Exception(ex.Message.ToString());
}
finally
{
conn.Close();
}
}

這樣就OK了
 

 

2013-06-19_234029

 

分享:asp.net頁(yè)面?zhèn)髦禍y(cè)試實(shí)例代碼
WebForm_1.aspx內(nèi)容如下: 復(fù)制代碼 代碼如下: %@ Page Language=C# AutoEventWireup=true CodeBehind=WebForm_1.aspx.cs Inherits=頁(yè)面?zhèn)髦?WebForm_1 % !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transit

來(lái)源:模板無(wú)憂//所屬分類:.Net教程/更新時(shí)間:2013-07-01
相關(guān).Net教程