错误:无效的对象名称
问题描述:
在web.config中
in web.config
<appSettings>
<add key="ConnectionString" value="Data Source=SAYAN-PC;Initial Catalog=MyPhotos;User ID=sa;Password=lock"/>
<add key="MyPhotos" value="TEST_TABLE1"/>
<add key="TitleField" value="1"/>
<add key="RatedByField" value="2"/>
<add key="ScoreField" value="3"/>
</appSettings>
并在.cs
中
and in .cs
string p = "Select * from " + ConfigurationSettings.AppSettings["MyPhotos"] + " WHERE id = '" + Convert.ToInt32(Request.QueryString["id"]) + "'";
调试后出现以下错误
after debugging i get the following error
报价:
错误:对象名称无效TEST_TABLE1
Error: Invalid object name TEST_TABLE1
答
它表示表"TEST_TABLE1"不存在.确保在"MyPhotos"表中有此表.
It means table "TEST_TABLE1" does not exists. make sure you have this table in "MyPhotos" table.
您好,
您可以显示更多代码吗?可能您尝试对MyPhotos以外的其他数据库执行此查询.此错误消息表示未在db中创建TEST_TABLE.
问候
罗伯特
Hi,
can you show more code? probably you try to execute this query against other db than MyPhotos. This error message indicates, that TEST_TABLE is not created in db.
Regards
Robert