Friday 12 October 2012

Microsoft Report rdlc data fill without using Dataset.xsd


Microsoft Report rdlc data fill without using Dataset.xsd

Create a formà add Microsoft report Viwer


Open rdlc with xml


Create on report datasource

Then define dataset column which you want to show on report

Drag and drop table in report

Right click on column expression  and double click on field the ok.


Result


Cs form code with windows form and web form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting;
using Microsoft.Reporting.WinForms;

namespace TransactMarketPlus.ADMIN
{
    public partial class RegisterUserInfo : Form
    {
        public RegisterUserInfo()
        {
            InitializeComponent();
        }
        dataUtility appTMP = new dataUtility();
        private void RegisterUserInfo_Load(object sender, EventArgs e)
        {
            TreeFill();
            this.reportViewer1.RefreshReport();
            string ClientId="";
            ReportFill(ClientId);
            this.reportViewer1.RefreshReport();
        }
        private void TreeFill()
        {//----------Client Id Fill
            DataTable dtClientId = appTMP.executeStoteProc("EXEC SP_SHOWDATA 1");
            TreeNode tNode = trvUser.Nodes.Add("Client Id");
            foreach (DataRow _item in dtClientId.Rows)
            {
                tNode.Nodes.Add(_item[0].ToString());
            }
            trvUser.ExpandAll();
        }
        private void ReportFill(string ClientId)
        {//-- windows code
            reportViewer1.Reset();
            this.reportViewer1.LocalReport.ReportPath = Application.StartupPath.ToString() + "/Reports/UserReport.rdlc";
            ReportDataSource rds = new ReportDataSource("DataSet1_DataTable1", appTMP.executeStoteProc("Exec Sp_showData 2"));
            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(rds);
            this.reportViewer1.LocalReport.Refresh();

            //--------------on web code
            //this.ReportViewer1.Reset();
            //this.ReportViewer1.LocalReport.ReportPath = Server.MapPath("Report.rdlc");
            //ReportDataSource rds = new ReportDataSource("dsNewDataSet_Table", getData());
            //this.ReportViewer1.LocalReport.DataSources.Clear();
            //this.ReportViewer1.LocalReport.DataSources.Add(rds);
            //this.ReportViewer1.DataBind();
            //this.ReportViewer1.LocalReport.Refresh();
        }
    }
}

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
  <DataSources>
    <DataSource Name="DummyDataSource">
      <rd:DataSourceID>4658dc3b-09af-4fe5-9abd-98a81a0942b2</rd:DataSourceID>
      <ConnectionProperties>
        <DataProvider>
        </DataProvider>
        <ConnectString>
        </ConnectString>
      </ConnectionProperties>
    </DataSource>
  </DataSources>
  <InteractiveHeight>11in</InteractiveHeight>
  <rd:DrawGrid>true</rd:DrawGrid>
  <InteractiveWidth>8.5in</InteractiveWidth>
  <rd:SnapToGrid>true</rd:SnapToGrid>
  <RightMargin>1in</RightMargin>
  <LeftMargin>1in</LeftMargin>
  <BottomMargin>1in</BottomMargin>
  <rd:ReportID>ffc920b5-5470-4847-9067-8474943ea741</rd:ReportID>
  <DataSets>
    <DataSet Name="DataSet1_DataTable1">
      <Fields>
        <Field Name="UserName">
          <DataField>UserName</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="ClientId">
          <DataField>ClientId</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
      </Fields>
      <Query>
        <DataSourceName>DummyDataSource</DataSourceName>
        <CommandText>
        </CommandText>
        <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
      </Query>
      <rd:DataSetInfo>
        <rd:DataSetName>DataSet1</rd:DataSetName>
        <rd:TableName>DataTable1</rd:TableName>
        <rd:TableAdapterName>
        </rd:TableAdapterName>
        <rd:TableAdapterFillMethod>
        </rd:TableAdapterFillMethod>
        <rd:TableAdapterGetDataMethod>
        </rd:TableAdapterGetDataMethod>
      </rd:DataSetInfo>
    </DataSet>
  </DataSets>
  <Width>6.50001in</Width>
  <Body>
    <ReportItems>
      <Table Name="table1">
        <Top>0.75in</Top>
        <Details>
          <TableRows>
            <TableRow>
              <TableCells>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox4">
                      <rd:DefaultName>textbox4</rd:DefaultName>
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>=Fields!UserName.Value</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox5">
                      <rd:DefaultName>textbox5</rd:DefaultName>
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>=Fields!ClientId.Value</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox6">
                      <rd:DefaultName>textbox6</rd:DefaultName>
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value />
                    </Textbox>
                  </ReportItems>
                </TableCell>
              </TableCells>
              <Height>0.25in</Height>
            </TableRow>
          </TableRows>
        </Details>
        <Header>
          <TableRows>
            <TableRow>
              <TableCells>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox1">
                      <rd:DefaultName>textbox1</rd:DefaultName>
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value />
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox2">
                      <rd:DefaultName>textbox2</rd:DefaultName>
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value />
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox3">
                      <rd:DefaultName>textbox3</rd:DefaultName>
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value />
                    </Textbox>
                  </ReportItems>
                </TableCell>
              </TableCells>
              <Height>0.25in</Height>
            </TableRow>
          </TableRows>
        </Header>
        <TableColumns>
          <TableColumn>
            <Width>2.16667in</Width>
          </TableColumn>
          <TableColumn>
            <Width>2.16667in</Width>
          </TableColumn>
          <TableColumn>
            <Width>2.16667in</Width>
          </TableColumn>
        </TableColumns>
        <Height>0.75in</Height>
        <Footer>
          <TableRows>
            <TableRow>
              <TableCells>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox7">
                      <rd:DefaultName>textbox7</rd:DefaultName>
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value />
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox8">
                      <rd:DefaultName>textbox8</rd:DefaultName>
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value />
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox9">
                      <rd:DefaultName>textbox9</rd:DefaultName>
                      <Style>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value />
                    </Textbox>
                  </ReportItems>
                </TableCell>
              </TableCells>
              <Height>0.25in</Height>
            </TableRow>
          </TableRows>
        </Footer>
      </Table>
    </ReportItems>
    <Height>2in</Height>
  </Body>
  <Language>en-US</Language>
  <TopMargin>1in</TopMargin>
</Report>

No comments:

Post a Comment