ASP.NET核心问题与IIS中的DB2查询有关

时间:2018-01-29 19:30:17

标签: c# asp.net iis db2 .net-core

我正在使用VS2015中的ASP.Net Core v1.0中的Web应用程序。此应用程序的前提是从DB2数据库中检索信息并显示给我们的调度程序使用。我遇到的问题是在我的开发PC上,应用程序在IIS Express中正常运行但是一旦部署我就会收到以下错误:

  

指数(基于零)必须大于或等于零。

所以我知道我的查询没有结果,我尝试更改IIS中的设置,但我似乎无法让它工作。在我的PC上进行调试时,检索并正确显示结果。这也是检索控制器背后的代码:

public ViewResult EvvCityFull()
    {

        DB2Command myDB2Command = null;
        string myDb2ConnectionString = "Server=Server;Database=DB;UID=User;PWD=Pass;";
        DB2Connection myDb2Connection = new DB2Connection(myDb2ConnectionString);
        myDb2Connection.Open();
        myDB2Command = myDb2Connection.CreateCommand();
        myDB2Command.CommandText = "SELECT DISTINCT FINAL_DRIVERS.DRIVER_ID, FINAL_DRIVERS.NAME, FINAL_DRIVERS.STATUS, FINAL_DRIVERS.REMAINING_HOURS, FINAL_DRIVERS.LAST_SAT_LOC, FINAL_DRIVERS.LAST_SAT_DATE FROM " +
                                   "(" +
                                   "SELECT BASE_DRIVERS.DRIVER_ID, BASE_DRIVERS.NAME, BASE_DRIVERS.STATUS, BASE_DRIVERS.REMAINING_HOURS, BASE_DRIVERS.LAST_SAT_LOC, BASE_DRIVERS.LAST_SAT_DATE, DATA AS EMPLOYMENT " +
                                   "FROM " +
                                   "(" +
                                   "SELECT BOARD_DRIVERS.DRIVER_ID, BOARD_DRIVERS.NAME, BOARD_DRIVERS.STATUS, BOARD_DRIVERS.REMAINING_HOURS, BOARD_DRIVERS.LAST_SAT_LOC, BOARD_DRIVERS.LAST_SAT_DATE, DATA AS CITY " +
                                   "FROM " +
                                   "(" +
                                   "SELECT DRIVER_ID, NAME, STATUS, REMAINING_HOURS, LAST_SAT_LOC, LAST_SAT_DATE, DATA AS BOARD FROM TMWIN.DRIVER, TMWIN.CUSTOM_DATA " +
                                   "WHERE DRIVER_ID = SRC_TABLE_KEY " +
                                   "AND ACTIVE_IN_DISP = 'True' " +
                                   "AND CUSTDEF_ID = 6 " +
                                   "AND DATA IN('CITY') " +
                                   "AND REMAINING_HOURS IS NOT NULL " +
                                   "AND STATUS IS NOT NULL " +
                                   ") BOARD_DRIVERS, " +
                                   "TMWIN.CUSTOM_DATA " +
                                   "WHERE BOARD_DRIVERS.DRIVER_ID = SRC_TABLE_KEY " +
                                   "AND CUSTDEF_ID = 7 " +
                                   "AND DATA IN('EVANSVILLE') " +
                                   ") BASE_DRIVERS, " +
                                   "TMWIN.CUSTOM_DATA " +
                                   "WHERE BASE_DRIVERS.DRIVER_ID = SRC_TABLE_KEY " +
                                   "AND CUSTDEF_ID = 9 " +
                                   "AND DATA IN('FULL-TIME') " +
                                   ") FINAL_DRIVERS LEFT JOIN TMWIN.CUSTOM_DATA " +
                                   "ON FINAL_DRIVERS.DRIVER_ID = SRC_TABLE_KEY ORDER BY FINAL_DRIVERS.DRIVER_ID ASC";
        DB2DataReader myDb2DataReader = null;
        List<Driver> result = new List<Driver>();

        using (myDb2DataReader = myDB2Command.ExecuteReader())
        {
            while (myDb2DataReader.Read())
            {

                Driver driver = new Driver();
                driver.DRIVER_ID = myDb2DataReader["DRIVER_ID"].ToString();
                driver.NAME = myDb2DataReader["NAME"].ToString();
                driver.STATUS = myDb2DataReader["STATUS"].ToString();
                driver.REMAINING_HOURS = Convert.ToDouble(myDb2DataReader["REMAINING_HOURS"].ToString());
                driver.LAST_SAT_LOC = myDb2DataReader["LAST_SAT_LOC"].ToString();
                driver.LAST_SAT_DATE = Convert.ToDateTime(myDb2DataReader["LAST_SAT_DATE"].ToString());
                result.Add(driver);

            }
        }
        myDb2DataReader.Close();
        myDB2Command.Dispose();
        myDb2Connection.Close();
        ViewBag.Drivers = result;

        return View(ViewBag.Drivers);
    }

我无法弄清楚使这个查询工作的环境有什么不同,并在我的机器上返回适当的数据但在部署时无法返回任何内容。如果有人对我有任何答案,我将不胜感激,谢谢。

0 个答案:

没有答案