C# System.Data.SqlClient.SqlException:“无效的对象名称更新”
服务1.csC# 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
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。我还检查了数据库中是否存在表更新。我是新手,下一步该怎么办?谢谢。我得到了一个问题,我忘了在上面的查询中添加我的数据库名。谢谢你的帮助!