Generating report using TableAdapters returns Null in ASP.Net MVC

Last Reply one year ago By bigbear

Posted one year ago

Hello community,

I have an MVC project that is trying to print reports. I have a .rdlc report that is showing information. I also have my project using entity framework. I am currently trying to get a generated report on specific records that are picked. I have all the records from the db in my project working fine and they can select them but when I am calling the method with the tableadapter to generate the report its getting null.

It brings me to the model.edmx dataset designer and where the connection says 

        if ((this._connection == null)) {
            this.InitConnection(); // the object is null. 
        // Here is the part of the code where the tableadapter is doing the method.
        public List<requiredReportListElements> getReportListInfo(List<findPartNumberListAttributes> current)
            /* Database for Version 1.x.x Adept AMAZON [was 'db'] */
            PartNumberDataSet dataSet = new PartNumberDataSet();
            PartNumberDataSetTableAdapters.EverythingForReportTableAdapter tableAdapter = new PartNumberDataSetTableAdapters.EverythingForReportTableAdapter();

            /* Database for Version 2.x.x  TRACKER_TEST*/
            //TRACKER_TESTDataSet dataSet = new TRACKER_TESTDataSet();
            //TRACKER_TESTDataSetTableAdapters.EverythingForReportTableAdapter tableAdapter = new TRACKER_TESTDataSetTableAdapters.EverythingForReportTableAdapter();

            List<requiredReportListElements> allParts = new List<requiredReportListElements>();

            foreach (var element in current)
                tableAdapter.FillBy(dataSet.EverythingForReport, element.partNumber);
                //var somethin = tableAdapter.GetDataBy(element.partNumber);
                var part = (from n in dataSet.EverythingForReport//somethin//
                            select new requiredReportListElements
        public ActionResult purchasePartReport(string command, FindPartModel list)
            /* Database Amazon Adept V2 */

            AmazonPartNumberDataSet db = new AmazonPartNumberDataSet();
            AmazonPartNumberDataSetTableAdapters.EverythingForReportTableAdapter tb = new AmazonPartNumberDataSetTableAdapters.EverythingForReportTableAdapter();
            LocalReport localReport = new LocalReport();
            localReport.ReportPath = Server.MapPath("~/ReportForms/purchasePartReport.rdlc");
            List<AmazonPartNumberDataSet.EverythingForReportRow> report = new List<AmazonPartNumberDataSet.EverythingForReportRow>();
            foreach (var item in list.requiredOnReportList)
            ReportDataSource rds = new ReportDataSource("EverythingForReports", report);
Posted one year ago

I ended up going in the designer and changing these to null and i got it working

            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "")]
            public string PartNumber {
                get {
                    try {
                        return ((string)(this[this.tableEverythingForReport.PartNumberColumn]));
                    catch (global::System.InvalidCastException e) {
                        //throw new global::System.Data.StrongTypingException("The value for column \'PartNumber\' in table \'EverythingForReport\' is DBNull.", e);
                        return null;
                set {
                    this[this.tableEverythingForReport.PartNumberColumn] = value;