how to create a reportViewer using a dataset

Asked

Viewed 44 times

0

hi would like to know how it creates data table from a select and save as PDF

code used

namespace WindowsFormsApp1.dbSetTableAdapters
{
    [Designer("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), HelpKeyword("vs.data.TableAdapter"), ToolboxItem(true), DataObject(true), DesignerCategory("code")]
    public class INSPECAO_PRINT_SELTableAdapter : Component
    {
        private SqlDataAdapter _adapter;
        private SqlConnection _connection;
        private SqlTransaction _transaction;
        private SqlCommand[] _commandCollection;
        private bool _clearBeforeFill;

        [GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0"), DebuggerNonUserCode]
        public INSPECAO_PRINT_SELTableAdapter()
        {
            //this.ClearBeforeFill = true;
        }

        [GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0"), DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter"), DataObjectMethod(DataObjectMethodType.Fill, true)]
        public virtual int Fill(WindowsFormsApp1.DataSet1.INSPECAO_PRINT_SELDataTable dataTable, int? idOs)
        {
            this.Adapter.SelectCommand = this.CommandCollection[0];
            this.Adapter.SelectCommand.Parameters[1].Value = (idOs == null) ? ((object)DBNull.Value) : ((object)idOs.Value);
            if (this.ClearBeforeFill)
            {
                dataTable.Clear();
            }
            return this.Adapter.Fill(dataTable);
        }

        [DebuggerNonUserCode, HelpKeyword("vs.data.TableAdapter"), GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0"), DataObjectMethod(DataObjectMethodType.Select, true)]
        public virtual WindowsFormsApp1.DataSet1.INSPECAO_PRINT_SELDataTable GetData(int? idOs)
        {
            this.Adapter.SelectCommand = this.CommandCollection[0];
            this.Adapter.SelectCommand.Parameters[1].Value = (idOs == null) ? ((object)DBNull.Value) : ((object)idOs.Value);
            WindowsFormsApp1.DataSet1.INSPECAO_PRINT_SELDataTable dataTable = new WindowsFormsApp1.DataSet1.INSPECAO_PRINT_SELDataTable();
            this.Adapter.Fill(dataTable);
            return dataTable;
        }

        [GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0"), DebuggerNonUserCode]
        private void InitAdapter()
        {
            this._adapter = new SqlDataAdapter();
            DataTableMapping mapping = new DataTableMapping
            {
                SourceTable = "Table",
                DataSetTable = "INSPECAO_PRINT_SEL",
                ColumnMappings = {
                    {
                        "ST_EMPRESA",
                        "ST_EMPRESA"
                    },
                    {
                        "ST_PECA",
                        "ST_PECA"
                    },
                    {
                        "ST_DESENHO",
                        "ST_DESENHO"
                    },
                    {
                        "dtCriado",
                        "dtCriado"
                    },
                    {
                        "ID_PEDIDO_CLIENTE",
                        "ID_PEDIDO_CLIENTE"
                    },
                    {
                        "NM_QUANTIDADE",
                        "NM_QUANTIDADE"
                    },
                    {
                        "ST_FUNCIONARIO",
                        "ST_FUNCIONARIO"
                    },
                    {
                        "aprovado",
                        "aprovado"
                    },
                    {
                        "dimensaoSolicitada",
                        "dimensaoSolicitada"
                    },
                    {
                        "encontrada",
                        "encontrada"
                    },
                    {
                        "instrumento",
                        "instrumento"
                    },
                    {
                        "aprovadoPeca",
                        "aprovadoPeca"
                    },
                    {
                        "durezaSolicitada",
                        "durezaSolicitada"
                    },
                    {
                        "durezaEncontrada",
                        "durezaEncontrada"
                    },
                    {
                        "idOsTT",
                        "idOsTT"
                    },
                    {
                        "aprovadoTT",
                        "aprovadoTT"
                    },
                    {
                        "observacao",
                        "observacao"
                    },
                    {
                        "toleranciaN",
                        "toleranciaN"
                    },
                    {
                        "toleranciaP",
                        "toleranciaP"
                    }
                }
            };
            this._adapter.TableMappings.Add(mapping);
        }

        [GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0"), DebuggerNonUserCode]
        private void InitCommandCollection()
        {
            this._commandCollection = new SqlCommand[] { new SqlCommand() };
            this._commandCollection[0].Connection = this.Connection;
            this._commandCollection[0].CommandText = "dbo.INSPECAO_PRINT_SEL";
            this._commandCollection[0].CommandType = CommandType.StoredProcedure;
            this._commandCollection[0].Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
            this._commandCollection[0].Parameters.Add(new SqlParameter("@idOs", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
        }

        [DebuggerNonUserCode, GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
        private void InitConnection()
        {
            this._connection = new SqlConnection();
            this._connection.ConnectionString = WindowsFormsApp1.Properties.Settings.Default.dbwehler;
        }

        [GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0"), DebuggerNonUserCode]
        protected internal SqlDataAdapter Adapter
        {
            get
            {
                if (this._adapter == null)
                {
                    this.InitAdapter();
                }
                return this._adapter;
            }
        }

        [GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0"), DebuggerNonUserCode]
        internal SqlConnection Connection
        {
            get
            {
                if (this._connection == null)
                {
                    this.InitConnection();
                }
                return this._connection;
            }
            set
            {
                this._connection = value;
                if (this.Adapter.InsertCommand != null)
                {
                    this.Adapter.InsertCommand.Connection = value;
                }
                if (this.Adapter.DeleteCommand != null)
                {
                    this.Adapter.DeleteCommand.Connection = value;
                }
                if (this.Adapter.UpdateCommand != null)
                {
                    this.Adapter.UpdateCommand.Connection = value;
                }
                for (int i = 0; i < this.CommandCollection.Length; i++)
                {
                    if (this.CommandCollection[i] != null)
                    {
                        this.CommandCollection[i].Connection = value;
                    }
                }
            }
        }

        [GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0"), DebuggerNonUserCode]
        internal SqlTransaction Transaction
        {
            get =>
                this._transaction;
            set
            {
                this._transaction = value;
                for (int i = 0; i < this.CommandCollection.Length; i++)
                {
                    this.CommandCollection[i].Transaction = this._transaction;
                }
                if ((this.Adapter != null) && (this.Adapter.DeleteCommand != null))
                {
                    this.Adapter.DeleteCommand.Transaction = this._transaction;
                }
                if ((this.Adapter != null) && (this.Adapter.InsertCommand != null))
                {
                    this.Adapter.InsertCommand.Transaction = this._transaction;
                }
                if ((this.Adapter != null) && (this.Adapter.UpdateCommand != null))
                {
                    this.Adapter.UpdateCommand.Transaction = this._transaction;
                }
            }
        }

        [GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0"), DebuggerNonUserCode]
        protected SqlCommand[] CommandCollection
        {
            get
            {
                if (this._commandCollection == null)
                {
                    this.InitCommandCollection();
                }
                return this._commandCollection;
            }
        }

        [GeneratedCode("System.Data.Design.TypedDataSetGenerator", "4.0.0.0"), DebuggerNonUserCode]
        public bool ClearBeforeFill
        {
            get =>
                this._clearBeforeFill;
            //set =>
            //    (this._clearBeforeFill = value);
        }
    }
}
  • RDL or RDLC, you have installed the SSDT?

  • I can’t tell you know where the SSDT goes down

  • ja comsegi valeu

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.