dt.Tablename =“ demoproject”;托管后无法在Web服务中使用

时间:2018-11-15 10:02:15

标签: iis

Web服务GetEmployeDetails(string empid)方法完全可以在localhost中运行,但是在发布它和另一个使用该方法的Windows应用程序之后,没有任何数据返回。

using System;
using System.Collections.Generic;
using System.Linq;

using System.Web;
using System.Web.Services;
using System.Data;


namespace TCTimeTrackerWS.Employee
{
    /// <summary>
    /// Summary description for Employee
    /// </summary>
    [WebService(Namespace = "http://192.168.31.240/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Employee : System.Web.Services.WebService
    {
       [WebMethod]
        public DataTable GetEmployeDetails(string empid)
        {
            try
            {
                DataTable dt = DBHelperClass.FilldataTableUsingQuery(@"Select firstname,lastname From  MST_Employee WHere employeid='"+empid+"'");
                dt.TableName = "empdetails";

                if (dt.Rows.Count > 0)
                {
                    return dt;
                }
            }
            catch { }
            return null;
        }
    }
 }

在localhost中,此代码工作正常,但在IIS Express中,它在dt.TableName =“ empdetails”下面的行中给我一个错误;

这会给我错误: System.NullReferenceException:对象引用未设置为对象的实例。    在E:\ Work Space 2 \ tcprojs \ WebService \ TCTimeTrackerWS \ TCTimeTrackerWS \ GetProject_webservice \ GetProject.asmx.cs:line 27

中的TCTimeTrackerWS.GetProject_webservice.GetProject.GetProjectByEmployee(String employeeid)

如何解决?预先感谢...

0 个答案:

没有答案