none
Erro ReportView RRS feed

  • Pergunta

  • Estou tentando abrir meu relatorio e esta dando o seguinte erro:
    A data source instance has not been supplied for the data source 'isotec_engDataSet_SE_EFETIVOE'.

    Segue abaixo o codigo que usei para abrir o relatório em C#:
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                rptEfetivo.ProcessingMode = ProcessingMode.Local;
                LocalReport report = rptEfetivo.LocalReport;
                report.ReportPath = "ReportEfetivo.rdlc";
                ReportDataSource rdsEfetivo = new ReportDataSource();
                rdsEfetivo.Name = "DsEfetivo_dtEfetivo";
                rdsEfetivo.Value = getEfetivo();
                report.DataSources.Add(rdsEfetivo);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }

        protected DataTable getEfetivo()
        {
            SqlConnection cnEfetivo = new SqlConnection(@"Data Source=202.74.53.23;Initial Catalog=isotec_eng;Persist Security Info=True;User ID=isotec_eng;Password=MIC-teste");
            SqlCommand cmdEfetivo = new SqlCommand("SELECT CC,FUNCAO,SETOR,NOME FROM SE_EFETIVOE",cnEfetivo);
            SqlDataAdapter daEfetivo = new SqlDataAdapter(cmdEfetivo);
            DataTable dtEfetivo = new DataTable();
            try
            {
                daEfetivo.Fill(dtEfetivo);
                return dtEfetivo;
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            finally
            {
                cnEfetivo.Dispose();
                cmdEfetivo.Dispose();
                daEfetivo.Dispose();
            }
            return null;
        }

    segunda-feira, 13 de outubro de 2008 20:06

Respostas

  • Paulo,

     

    Em VB.NET eu faço da seguinte forma:

     

    Code Snippet

    'provider do banco de dados

    Imports System.Data.SqlServerCe

    Imports System.Data

    'reportview

    Imports Microsoft.Reporting.WinForms

    'outros

    Imports System.Text 'StringBuilder

    Imports System.Configuration 'ConnectionStrings

    Imports System.IO 'Path.Combine

     

     

     

    Code Snippet

    Private Sub PreviewRelClientes(ByVal oTable As DataTable)

    Try

     

    '1 passo: definindo o relat¢rio a ser visualizado

    rvPreview.LocalReport.ReportEmbeddedResource = "AWorksCE.rdlCustomer.rdlc"

     

    '2 passo: definindo o DataSource do relat¢rio

    Dim myReportDataSource As ReportDataSource = _

    New ReportDataSource("dsCustomer", oTable)

    rvPreview.LocalReport.DataSources.Add(myReportDataSource)

     

    Catch ex As Exception

    MsgBox(ex.Message)

    End Try

    End Sub

     

     

    Code Snippet

     

    Private Function CarregarListaClientes() As DataTable

    'definindo a string de conexÆo do banco de dados

    Dim strConexao As String = _

    ConfigurationManager.ConnectionStrings("SQLServerCompact").ToString

    Dim oConn As New SqlCeConnection(strConexao)

    Dim strSQL As New StringBuilder

    Dim oTable As New DataTable()

    Dim oCmd As SqlCeCommand = Nothing

    Try

    'abrindo conexÆo com o banco de dados.

    oConn.Open()

    'definindo o SQL

    strSQL.Append(" Select CustomerID ")

    strSQL.Append(" ,CustomerName")

    strSQL.Append(" ,Phone")

    strSQL.Append(" ,EmailAddress")

    strSQL.Append(" ,AddressLine")

    strSQL.Append(" ,City")

    strSQL.Append(" ,StateProvinceName")

    strSQL.Append(" ,PostalCode")

    strSQL.Append(" ,CountryName")

    strSQL.Append(" ,LastUpdate ")

    strSQL.Append(" FROM Customer inner join Country ")

    strSQL.Append(" on Customer.CountryID = Country.CountryID ")

    strSQL.Append(" Order by CountryName, CustomerName ")

    'carregando os dados do banco de dados

    Dim oDA As New SqlCeDataAdapter(strSQL.ToString, oConn)

    oDA.Fill(oTable)

    Catch ex As Exception

    MsgBox(ex.Message)

    Finally

    'liberando os objetos

    oConn.Dispose()

    oConn = Nothing

    End Try

    Return oTable

    End Function

     

     

    Code Snippet

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

     

    If Not Page.IsPostBack Then

     

    PreviewRelClientes(CarregarListaClientes())

    rvPreview.RefreshReport()

     

    End If

     

    End Sub

     

     

    [ ]'s

     

    Laércio.

     

    terça-feira, 14 de outubro de 2008 15:15
    Moderador