Skip to main content
adicionou 10 caracteres ao conteúdo
Fonte Link
rray
  • 67,7mil
  • 21
  • 116
  • 285

podem me passar um modelo para popular um Rpt sem o DATASET?

o que eu uso nao esta dando certo., segue modelo que uso.

private void Carregar() {

DateTime dt1; dt1 = dtpickerInicial.Value; DateTime dt2; dt2 = dtpickerFinal.Value;

private void Carregar()
{

DateTime dt1; dt1 = dtpickerInicial.Value;
            DateTime dt2; dt2 = dtpickerFinal.Value;

        SqlCommand cmd = new SqlCommand();
        SqlDataAdapter da = new SqlDataAdapter();
        DataSet dsum = new DataSet();
        DataTable oTable = new DataTable();
        string strReportPath = "";

        try
        {
            strReportPath = @"rptRelatorioCaixa.rdlc";
            reportViewer1.LocalReport.ReportPath = strReportPath;
            SqlConnection conn = new SqlConnection(Properties.Settings.Default.BD_OneDrive );
            cmd.Connection = conn;
            cmd.CommandText = "SELECT * FROM CAIXA"; // Where dataSaida between @dtini and @dtfim ";

            cmd.CommandType = CommandType.Text;
            conn.Open();

            SqlDataReader oDataReader = cmd.ExecuteReader();
            oTable.Load(oDataReader);
            ReportDataSource myReportDataSource = new ReportDataSource(oTable);// da erro pois me cobra um dataSet
            reportViewer1.LocalReport.EnableExternalImages = true;
            //ReportParameter p = new ReportParameter("Titulo", "Resultado parcial do mes");
            //this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p });
            
            reportViewer1.Clear();
            if (reportViewer1.LocalReport.DataSources.Count > 0)
                reportViewer1.LocalReport.DataSources[0] = myReportDataSource;
            else
                reportViewer1.LocalReport.DataSources.Add(myReportDataSource);

            reportViewer1.RefreshReport();

podem me passar um modelo para popular um Rpt sem o DATASET?

o que eu uso nao esta dando certo., segue modelo que uso.

private void Carregar() {

DateTime dt1; dt1 = dtpickerInicial.Value; DateTime dt2; dt2 = dtpickerFinal.Value;

        SqlCommand cmd = new SqlCommand();
        SqlDataAdapter da = new SqlDataAdapter();
        DataSet dsum = new DataSet();
        DataTable oTable = new DataTable();
        string strReportPath = "";

        try
        {
            strReportPath = @"rptRelatorioCaixa.rdlc";
            reportViewer1.LocalReport.ReportPath = strReportPath;
            SqlConnection conn = new SqlConnection(Properties.Settings.Default.BD_OneDrive );
            cmd.Connection = conn;
            cmd.CommandText = "SELECT * FROM CAIXA"; // Where dataSaida between @dtini and @dtfim ";

            cmd.CommandType = CommandType.Text;
            conn.Open();

            SqlDataReader oDataReader = cmd.ExecuteReader();
            oTable.Load(oDataReader);
            ReportDataSource myReportDataSource = new ReportDataSource(oTable);// da erro pois me cobra um dataSet
            reportViewer1.LocalReport.EnableExternalImages = true;
            //ReportParameter p = new ReportParameter("Titulo", "Resultado parcial do mes");
            //this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p });
            
            reportViewer1.Clear();
            if (reportViewer1.LocalReport.DataSources.Count > 0)
                reportViewer1.LocalReport.DataSources[0] = myReportDataSource;
            else
                reportViewer1.LocalReport.DataSources.Add(myReportDataSource);

            reportViewer1.RefreshReport();

podem me passar um modelo para popular um Rpt sem o DATASET?

o que eu uso nao esta dando certo., segue modelo que uso.

private void Carregar()
{

DateTime dt1; dt1 = dtpickerInicial.Value;
            DateTime dt2; dt2 = dtpickerFinal.Value;

        SqlCommand cmd = new SqlCommand();
        SqlDataAdapter da = new SqlDataAdapter();
        DataSet dsum = new DataSet();
        DataTable oTable = new DataTable();
        string strReportPath = "";

        try
        {
            strReportPath = @"rptRelatorioCaixa.rdlc";
            reportViewer1.LocalReport.ReportPath = strReportPath;
            SqlConnection conn = new SqlConnection(Properties.Settings.Default.BD_OneDrive );
            cmd.Connection = conn;
            cmd.CommandText = "SELECT * FROM CAIXA"; // Where dataSaida between @dtini and @dtfim ";

            cmd.CommandType = CommandType.Text;
            conn.Open();

            SqlDataReader oDataReader = cmd.ExecuteReader();
            oTable.Load(oDataReader);
            ReportDataSource myReportDataSource = new ReportDataSource(oTable);// da erro pois me cobra um dataSet
            reportViewer1.LocalReport.EnableExternalImages = true;
            //ReportParameter p = new ReportParameter("Titulo", "Resultado parcial do mes");
            //this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p });
            
            reportViewer1.Clear();
            if (reportViewer1.LocalReport.DataSources.Count > 0)
                reportViewer1.LocalReport.DataSources[0] = myReportDataSource;
            else
                reportViewer1.LocalReport.DataSources.Add(myReportDataSource);

            reportViewer1.RefreshReport();
Fonte Link

erro ao atribuir uma query para preencher um reportView

podem me passar um modelo para popular um Rpt sem o DATASET?

o que eu uso nao esta dando certo., segue modelo que uso.

private void Carregar() {

DateTime dt1; dt1 = dtpickerInicial.Value; DateTime dt2; dt2 = dtpickerFinal.Value;

        SqlCommand cmd = new SqlCommand();
        SqlDataAdapter da = new SqlDataAdapter();
        DataSet dsum = new DataSet();
        DataTable oTable = new DataTable();
        string strReportPath = "";

        try
        {
            strReportPath = @"rptRelatorioCaixa.rdlc";
            reportViewer1.LocalReport.ReportPath = strReportPath;
            SqlConnection conn = new SqlConnection(Properties.Settings.Default.BD_OneDrive );
            cmd.Connection = conn;
            cmd.CommandText = "SELECT * FROM CAIXA"; // Where dataSaida between @dtini and @dtfim ";

            cmd.CommandType = CommandType.Text;
            conn.Open();

            SqlDataReader oDataReader = cmd.ExecuteReader();
            oTable.Load(oDataReader);
            ReportDataSource myReportDataSource = new ReportDataSource(oTable);// da erro pois me cobra um dataSet
            reportViewer1.LocalReport.EnableExternalImages = true;
            //ReportParameter p = new ReportParameter("Titulo", "Resultado parcial do mes");
            //this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p });
            
            reportViewer1.Clear();
            if (reportViewer1.LocalReport.DataSources.Count > 0)
                reportViewer1.LocalReport.DataSources[0] = myReportDataSource;
            else
                reportViewer1.LocalReport.DataSources.Add(myReportDataSource);

            reportViewer1.RefreshReport();