<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Visual Studio MVC integration, repeat data from store procedure]]></title><description><![CDATA[<p>Hi !<br />
i have learning a lot if things about jsreport this week. I try to integrate it with visual studio because it will make things easier....</p>
<p>I am trying to get data from stored procedure and its working but I can't make it work when I try to get more than one data and make it a table. I always get &quot;IndexOutOfRangeException&quot; and I believe its because of return function, here is the code :</p>
<pre><code class="language-cs">using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Threading.Tasks;
            using System.Data.SqlClient;
            using System.Collections;

        namespace NetWebApp.Model
    {
         public class InvoiceModel
    {
        public string ReferenceNumber { get; set; }
        public string AllocationType { get; set; }
        public string Contract { get; set; }
        public string EP { get; set; }
        public string json;
        public IEnumerable&lt;ItemModel&gt; Items { get; set; }

            public static InvoiceModel Example()
        {
            ArrayList objs = new ArrayList();

            SqlConnection sqlConnection1 = new SqlConnection(&quot;Data 
            Source=localhost\\VANDERSQL2K8R2;Initial 
            Catalog=PGPL_GMS_DEV;User ID=admin;Password=Password&quot;);  
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = &quot;[Approval].[rspSelAllocationSetupModification] '287','systemAdmin'&quot;;

            cmd.Connection = sqlConnection1;
            sqlConnection1.Open();

            SqlDataReader rdr = cmd.ExecuteReader();
            // Data is accessible through the DataReader object here.
            rdr.Read();
            
                return new InvoiceModel()
                    { // I success to cal these data
                        ReferenceNumber = rdr[&quot;ReferenceNumber&quot;].ToString(),
                        AllocationType = rdr[&quot;AllocationTypeName&quot;].ToString(),
                        Contract = rdr[&quot;ContractNumber&quot;].ToString(),
                        EP = rdr[&quot;AllocationPeriod&quot;].ToString(),

                        Items = new List&lt;ItemModel&gt;()
                    {
                     //whenever I try to call these data (item model), they got me error
                     //&quot;IndexOutOfRangeException&quot;

                      new ItemModel() {
                        AG = rdr[&quot;AllocationCategory&quot;].ToString(),
                        AP = rdr[&quot;AllocationParameter&quot;].ToString(),
                        CAM = rdr[&quot;CurrentAllocationMethod&quot;].ToString(),
                        CF = rdr[&quot;CurrentAllocationFormula&quot;].ToString(),
                        NAM = rdr[&quot;NewAllocationMethod&quot;].ToString(),
                        NF = rdr[&quot;NewAllocationFormula&quot;].ToString()
                }
        
                    }
                    };

            sqlConnection1.Close();
            
            }
    }

    public class ItemModel
    {
        public string AG { get; set; }
        public string AP { get; set; }
        public string CAM { get; set; }
        public string CF { get; set; }
        public string NAM { get; set; }
        public string NF { get; set; }
        public string json { get; set; }
    }}

</code></pre>
<p>I use <a href="https://github.com/jsreport/jsreport-dotnet-example-webapp" rel="nofollow">https://github.com/jsreport/jsreport-dotnet-example-webapp</a> as references.<br />
can anyone help ? Please .....<br />
thank you in advance</p>
]]></description><link>https://forum.jsreport.net/topic/604/visual-studio-mvc-integration-repeat-data-from-store-procedure</link><generator>RSS for Node</generator><lastBuildDate>Sun, 17 May 2026 11:31:12 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/604.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 03 Jul 2018 09:53:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Visual Studio MVC integration, repeat data from store procedure on Tue, 03 Jul 2018 16:18:41 GMT]]></title><description><![CDATA[<p>Hi !<br />
i have learning a lot if things about jsreport this week. I try to integrate it with visual studio because it will make things easier....</p>
<p>I am trying to get data from stored procedure and its working but I can't make it work when I try to get more than one data and make it a table. I always get &quot;IndexOutOfRangeException&quot; and I believe its because of return function, here is the code :</p>
<pre><code class="language-cs">using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Threading.Tasks;
            using System.Data.SqlClient;
            using System.Collections;

        namespace NetWebApp.Model
    {
         public class InvoiceModel
    {
        public string ReferenceNumber { get; set; }
        public string AllocationType { get; set; }
        public string Contract { get; set; }
        public string EP { get; set; }
        public string json;
        public IEnumerable&lt;ItemModel&gt; Items { get; set; }

            public static InvoiceModel Example()
        {
            ArrayList objs = new ArrayList();

            SqlConnection sqlConnection1 = new SqlConnection(&quot;Data 
            Source=localhost\\VANDERSQL2K8R2;Initial 
            Catalog=PGPL_GMS_DEV;User ID=admin;Password=Password&quot;);  
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = &quot;[Approval].[rspSelAllocationSetupModification] '287','systemAdmin'&quot;;

            cmd.Connection = sqlConnection1;
            sqlConnection1.Open();

            SqlDataReader rdr = cmd.ExecuteReader();
            // Data is accessible through the DataReader object here.
            rdr.Read();
            
                return new InvoiceModel()
                    { // I success to cal these data
                        ReferenceNumber = rdr[&quot;ReferenceNumber&quot;].ToString(),
                        AllocationType = rdr[&quot;AllocationTypeName&quot;].ToString(),
                        Contract = rdr[&quot;ContractNumber&quot;].ToString(),
                        EP = rdr[&quot;AllocationPeriod&quot;].ToString(),

                        Items = new List&lt;ItemModel&gt;()
                    {
                     //whenever I try to call these data (item model), they got me error
                     //&quot;IndexOutOfRangeException&quot;

                      new ItemModel() {
                        AG = rdr[&quot;AllocationCategory&quot;].ToString(),
                        AP = rdr[&quot;AllocationParameter&quot;].ToString(),
                        CAM = rdr[&quot;CurrentAllocationMethod&quot;].ToString(),
                        CF = rdr[&quot;CurrentAllocationFormula&quot;].ToString(),
                        NAM = rdr[&quot;NewAllocationMethod&quot;].ToString(),
                        NF = rdr[&quot;NewAllocationFormula&quot;].ToString()
                }
        
                    }
                    };

            sqlConnection1.Close();
            
            }
    }

    public class ItemModel
    {
        public string AG { get; set; }
        public string AP { get; set; }
        public string CAM { get; set; }
        public string CF { get; set; }
        public string NAM { get; set; }
        public string NF { get; set; }
        public string json { get; set; }
    }}

</code></pre>
<p>I use <a href="https://github.com/jsreport/jsreport-dotnet-example-webapp" rel="nofollow">https://github.com/jsreport/jsreport-dotnet-example-webapp</a> as references.<br />
can anyone help ? Please .....<br />
thank you in advance</p>
]]></description><link>https://forum.jsreport.net/post/3004</link><guid isPermaLink="true">https://forum.jsreport.net/post/3004</guid><dc:creator><![CDATA[BlackWizardMimi]]></dc:creator><pubDate>Tue, 03 Jul 2018 16:18:41 GMT</pubDate></item></channel></rss>