2016-09-21 28 views
1

你好,我有創建水晶報表C#, 報告的問題,我應該插入此SqlAdapter在AC#報告的結果,但不知道該怎麼辦如何添加數據集到報告C#

String Query = "SELECT Utente.LogoAzienda,Preventivo.DataInserimento,Preventivo.RiferimentoInterno,Preventivo.Testata,Preventivo.Chiusura,Cliente.Titolo,Cliente.RagioneSociale,Cliente.Indirizzo,Cliente.Cap,Cliente.Citta,Cliente.Provincia FROM Preventivo inner join Cliente on Cliente.IdCliente = Preventivo.IdCliente inner join Utente on Preventivo.UtenteCreazione = Utente.Username"; 

SqlConnection conn = db.apriconnessione(); 

DataStampaPreventivoCompleto d = new DataStampaPreventivoCompleto(); 
SqlDataAdapter da = new SqlDataAdapter(Query, conn); 
da.Fill(d, d.Tables[0].TableName); 

回答

2

這裏是綁定數據集水晶報表的例子:

private void CrystalFormView_Load(object sender, EventArgs e) 
{ 
    string connection = ConfigurationManager.ConnectionStrings["sqlbill"].ConnectionString; 
    string provider = ConfigurationManager.ConnectionStrings["sqlbill"].ProviderName; 
    SqlConnection con = new SqlConnection(connection); 
    SqlDataAdapter sda = new SqlDataAdapter("select product as Product,productid as ProductId,quantity as Quantity from productdata", con); 

    DataSet ds = new DataSet(); 
    sda.Fill(ds); 
    ds.Tables[0].TableName = "BILLTEST"; 

    BillCrystalReport bill = new BillCrystalReport(); 
    bill.SetDataSource(ds); 

    bill.VerifyDatabase(); 

    crystalReportViewer1.ReportSource = bill; 
    crystalReportViewer1.RefreshReport(); 
} 

如需更多信息,請點擊此鏈接:http://www.codeproject.com/Tips/754037/Bind-Crystal-Reports-with-Dataset-or-Datatable

+0

我有嘗試你的代碼,但視覺工作室打印此消息:一個unha mscorlib.dll 附加信息:無法加載文件或程序集'file:/// C:\ Program Files文件(x86)\ SAP BusinessObjects \ Crystal Reports for .NET「mscorlib.dll中發生類型'System.IO.FileNotFoundException' Framework 4.0 \ Common \ SAP BusinessObjects Enterprise XI 4.0 \ win32_x86 \ dotnet1 \ crdb_adoplus.dll'或其某個依賴關係。系統找不到指定的文件 –

+0

我已經解決了錯誤,謝謝 –

+0

@RikiDev這是一個很好的提示,可以解決問題的解決方案,而不是「修復它」,所以其他人可能會發現此線程將能夠解決它太。 –