Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将Linq中的存储过程调用为SQL,当调用db.Database.ExecuteSqlCommand时,我从表单集合返回-1获取数据_C#_Sql Server_Linq_Stored Procedures - Fatal编程技术网

C# 如何将Linq中的存储过程调用为SQL,当调用db.Database.ExecuteSqlCommand时,我从表单集合返回-1获取数据

C# 如何将Linq中的存储过程调用为SQL,当调用db.Database.ExecuteSqlCommand时,我从表单集合返回-1获取数据,c#,sql-server,linq,stored-procedures,C#,Sql Server,Linq,Stored Procedures,这里有谁能帮助我 如何将Linq中的存储过程调用为SQL,我从表单集合中获取数据,然后我想调用返回多行的存储过程,然后我想将其传递给视图(请告诉我如何使用受影响的行对象在没有模型的情况下显示数据) 我以这种方式调用存储过程,但它在行中为我提供=-1 [HttpPost] public ActionResult ReportTVPSA(FormCollection collection) { int fiscal_year

这里有谁能帮助我

如何将Linq中的存储过程调用为SQL,我从表单集合中获取数据,然后我想调用返回多行的存储过程,然后我想将其传递给视图(请告诉我如何使用受影响的行对象在没有模型的情况下显示数据) 我以这种方式调用存储过程,但它在行中为我提供=-1

          [HttpPost]
        public ActionResult ReportTVPSA(FormCollection collection)
        {
            int fiscal_year = int.Parse(collection["FinancialYearIDFrom"]);
            int prev_year = fiscal_year - 1;
            int month_frm = int.Parse(collection["MonthFrom"]);
            var month_to = collection["MonthTo"];
            string division = collection["dvn_code"];
            var rand = DBNull.Value;
            DateTime FDate, TDate;
            DateTime.TryParse(collection["dateFrom"], out FDate);
            var dateFrom = FDate;

            DateTime.TryParse(collection["dateTo"], out TDate);
            var date_to = TDate;

            string ReportBaseTypeDoOrInvoice = collection["ReportBaseTypeDoOrInvoice"];
            string ReportBaseTypeQuantityOrRevenue = collection["ReportBaseTypeQuantityOrRevenue"];

            int SegmentLevel = int.Parse(collection["SegmentLevel"]);
            string segment_codes = collection["segment_codes"];
            string sg_cd_frm = collection["sg_cd_frm"];
            string sg_cd_to = collection["sg_cd_to"];

            string location = collection["show_customers"];
            string cst_CodeFrom = collection["cst_CodeFrom"];
            string cst_CodeTo = collection["cst_CodeTo"];

            var rows = db.Database.ExecuteSqlCommand("sp_GetTargetVSPrimarySalesAnalysisForZones @FinancialYear, @PreviousFinancialYear, @Month, @dvn_code, @DateFrom, @DateTo, @ReportBaseTypeDoOrInvoice, @ReportBaseTypeQuantityOrRevenue, @SegmentLevel, @SegmentCode, @SegmentCodeFrom, @SegmentCodeTo, @cst_Code, @cst_CodeFrom, @cst_CodeTo",
                new SqlParameter("@FinancialYear", fiscal_year),
                new SqlParameter("@PreviousFinancialYear", prev_year),
                new SqlParameter("@Month", month_to),
                new SqlParameter("@dvn_code", division),
                new SqlParameter("@DateFrom", dateFrom),
                new SqlParameter("@DateTo", date_to),
                new SqlParameter("@ReportBaseTypeDoOrInvoice", ReportBaseTypeDoOrInvoice),
                new SqlParameter("@ReportBaseTypeQuantityOrRevenue", ReportBaseTypeQuantityOrRevenue),
                new SqlParameter("@SegmentLevel", SegmentLevel),
                new SqlParameter("@SegmentCode", rand),
                new SqlParameter("@SegmentCodeFrom", sg_cd_frm),
                new SqlParameter("@SegmentCodeTo", sg_cd_to),
                new SqlParameter("@cst_Code", rand),
                new SqlParameter("@cst_CodeFrom", cst_CodeFrom),
                new SqlParameter("@cst_CodeTo", cst_CodeTo));

            return View();
        }

SQL返回10减去错误的严重级别,如果得到-1,则严重级别为11,即SqlErrorCollection@LiviuBoboia你能告诉我怎么解决吗?在你的sql server上运行这个命令,看看这里有谁解决了我的问题?plzSQL返回10减去错误的严重级别,如果得到-1,则严重级别为11,即SqlErrorCollection@LiviuBoboia你能告诉我怎么解决吗?在你的sql server上运行这个命令,看看这里有谁解决了我的问题?请