SqlConnection con=DB.ctreatConnection();
con.Open();
SqlCommand cmd=new SqlCommand("select * from personLike",con);
SqlDataReader sdr=cmd.ExecuteReader();public class DB
{ public static SqlConnection ctreatConnection()
{
System.Data.SqlClient.SqlConnection con=new SqlConnection("server=.;database=login;uid=sa;pwd=;");
return con;
}
}
运行错误
对象名 'personLike' 无效。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 对象名 'personLike' 无效。源错误:
行 26: con.Open();
行 27: SqlCommand cmd=new SqlCommand("select * from personLike",con);
行 28: SqlDataReader sdr=cmd.ExecuteReader();
行 29: this.CheckBoxList2.DataTextField="likeContent";
行 30: this.CheckBoxList2.DataValueField="id";
源文件: c:\inetpub\wwwroot\webapplication4\webform4.aspx.cs 行: 28 但是我在查询分析器里执行select * from personLike的时候是正确的?????!!!!!
con.Open();
SqlCommand cmd=new SqlCommand("select * from personLike",con);
SqlDataReader sdr=cmd.ExecuteReader();public class DB
{ public static SqlConnection ctreatConnection()
{
System.Data.SqlClient.SqlConnection con=new SqlConnection("server=.;database=login;uid=sa;pwd=;");
return con;
}
}
运行错误
对象名 'personLike' 无效。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 对象名 'personLike' 无效。源错误:
行 26: con.Open();
行 27: SqlCommand cmd=new SqlCommand("select * from personLike",con);
行 28: SqlDataReader sdr=cmd.ExecuteReader();
行 29: this.CheckBoxList2.DataTextField="likeContent";
行 30: this.CheckBoxList2.DataValueField="id";
源文件: c:\inetpub\wwwroot\webapplication4\webform4.aspx.cs 行: 28 但是我在查询分析器里执行select * from personLike的时候是正确的?????!!!!!
con.Open();
SqlCommand cmd=new SqlCommand("select * from personLike",con);
try
{
cmd.ExecuteNonQuery();
}
catch{}
finally
{
cmd.Dispose();
conn.Close();
}public class DB
{ public static SqlConnection ctreatConnection()
{
System.Data.SqlClient.SqlConnection con=new SqlConnection("server=.;database=login;uid=sa;pwd=;");
return con;
}
}