Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.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# System.Data.SqlClient.SqlException:“无效的对象名称更新”_C#_Wcf - Fatal编程技术网

C# System.Data.SqlClient.SqlException:“无效的对象名称更新”

C# System.Data.SqlClient.SqlException:“无效的对象名称更新”,c#,wcf,C#,Wcf,服务1.cs namespace WcfServiceLibrary1 { public class Service1 : IService1 { public getempupdate[] Update(string EName) { { getempupdate g = new getempupdate(); SqlConnection

服务1.cs

namespace WcfServiceLibrary1
{
    public class Service1 : IService1
    {
        public getempupdate[] Update(string EName)
        {           
            {
                getempupdate g = new getempupdate();
                SqlConnection con = new SqlConnection("Server=localhost;Database=master;Trusted_Connection=True");
                con.Open();
                SqlCommand cmd = new SqlCommand("select EID, EName, EUpdate from EmpUpdates with (nolock) where EName = @EName", con);
                cmd.Parameters.AddWithValue("@EName", EName);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt); //Getting the error on this line
                con.Close();
                g.EmpUpdates = dt;
                return dt.ToList<getempupdate>().ToArray();
            }
        }    
    }
}

这通常表示该表不存在。检查你拼写是否正确


看起来您的连接字符串也指向一个名为“master”的数据库。这可能是错误的。您的数据库名是什么?

主数据库是SQL Server保留数据库,不用于用户数据。您好,Steve,我的数据库名是EmployeeUpdate。我还检查了数据库中是否存在表更新。我是新手,下一步该怎么办?谢谢。我得到了一个问题,我忘了在上面的查询中添加我的数据库名。谢谢你的帮助!