2016-10-17 9 views
1

ms-sql 서버 2014에서 저장 프로 시저를 만들고 rdlc 보고서를 만들었습니다. 이제 프로그래밍 방식의 ReportViewer 보고서를 바인딩하지만 보고서 만 열은 표시되어 있지 데이터를 ...데이터가 reportviewer에로드되지 않았습니다. VB.NET

아래의 코드 내 저장 프로 시저입니다 :의 ReportViewer 형태의 부하

USE [Bonny] 
GO 
/****** Object: StoredProcedure [dbo].[AccMast_AllDetail] Script Date: 17/10/2016 12:10:42 ******/ 
SET ANSI_NULLS ON 
GO 
SET QUOTED_IDENTIFIER ON 
GO 
ALTER Proc [dbo].[AccMast_AllDetail] 
as 
Select Account_Code,Party_Name,Address_1,Address_2,City from FAMPAR order by Account_Code 
GO 

내 VB.NET 코드 이벤트 ...

 ReportViewer.Reset() 
     Dim data As New AccMastDataSet 
     Dim ReportDataSource1 As ReportDataSource = New ReportDataSource 
     ReportDataSource1.Name = "AccMastDataSet" 
     ReportDataSource1.Value = rds 
     ReportViewer.LocalReport.DataSources.Clear() 
     ReportViewer.LocalReport.DataSources.Add(ReportDataSource1) 
     ReportViewer.LocalReport.ReportEmbeddedResource = "Report1.rdlc" 
     ReportViewer.LocalReport.ReportPath = "D:\netbonny\netbonnyproject\netbonnyproject\Reports\Report1.rdlc" 
     ReportViewer.RefreshReport() 
내가 열 머리글을 얻고이에서

아니라 데이터, 데이터가 및 SQL 관리 스튜디오에서 확인 ...

또 다른 VB. 내가 노력 NET 코드는 다음과 같습니다 여기

Dim data As New AccMastDataSet 
Dim abc = data.Tables("AccMast_AllDetail") 
Dim rds = New Microsoft.Reporting.WinForms.ReportDataSource("AccMastDataSet", data) 
ReportViewer.LocalReport.DataSources.Clear() 
ReportViewer.LocalReport.DataSources.Add(rds) 
ReportViewer.LocalReport.ReportEmbeddedResource = "netbonnyproject.Report1.rdlc" 
ReportViewer.RefreshReport() 

나는 점점 오전 오류 : 나는 그것을 말하는 아무 생각

enter image description here

...

여기에서 저를 도와주세요.

답변

2

현재 데이터 소스보고에 DataSet의 새 인스턴스 DataTable을 전달했습니다. 그래서 분명히 비어 있어야하며 데이터가없는 보고서 열 머리글이 표시됩니다.

데이터를 DataTable으로로드 한 다음보고하여 전달해야합니다. 또한

Me.Table1TableAdapter.Fill(Me.DataSet1.Table1) 
Dim rds = New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", Me.DataSet1.Table1) 

Dim cn = "Connection String" 
Dim cmd = "Stored Procedre Name" 
Dim table = New DataTable() 
Using adapter As New SqlDataAdapter(cmd, cn) 
    adapter.SelectCommand.CommandType = CommandType.StoredProcedure 
    adapter.Fill(table) 
End Using 
Dim rds = New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", table) 
+0

OMG : 당신은 당신의 폼에 TableAdapter을 떨어 뜨리면

는 예를 들어, 같은 코드를 사용할 수 있습니다! ReportViewer Atlast에 내 데이터를보고 행복합니다 ... #cry ........... Thanx alot. 그리고 나중에'Dim rds = New Microsoft.Reporting.WinForms.ReportDataSource ("DataSet1", table)'을 사용하지 않고'ReportDataSource1.Value = table'에 테이블을 직접 두었습니다. alot @RezaAghaei .. – bonny

+0

사실 두 개의 코드가 혼합되어 두 개의 ReportDataSource가 있습니다 ... 뭐든지간에, 나는 고맙다. 고맙습니다. 다시 고맙습니다. @RezaAghaei – bonny

+0

좋아요! 천만에요 :) –