问题描述
错误详情:
error details:
BaseDB.GetDataTableUsingQuery(SqlCommand oCommand, String sqlQuery) in e:\ClickPerk files\SampleSwan\App_Code\BaseDB.cs:57
Sample.GetNewSamplesWithCategories() in e:\ClickPerk files\SampleSwan\App_Code\Sample.cs:50
_Default.BindSamples() in e:\ClickPerk files\SampleSwan\Default.aspx.cs:16
_Default.Page_Load(Object sender, EventArgs e) in e:\ClickPerk files\SampleSwan\Default.aspx.cs:12
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +95
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678
******************* BaseDB.cs *****************
*******************BaseDB.cs*****************
public static DataTable GetDataTableUsingQuery(SqlCommand oCommand, string sqlQuery)
{
SqlConnection oConn = GetConnection();
DataTable oTable = new DataTable();
oCommand.Connection = oConn;
oCommand.CommandText = sqlQuery;
oCommand.CommandTimeout = 90;
oCommand.CommandType = CommandType.Text;
SqlDataAdapter oAdapter = new SqlDataAdapter();
oAdapter.SelectCommand = oCommand;
try
{
oAdapter.Fill(oTable);
}
catch (Exception e)
{
throw e;
}
return oTable;
}
************** Sample.cs ***** ************
**************Sample.cs*****************
public static DataTable GetNewSamplesWithCategories()
{
return BaseDB.GetDataTableUsingQuery(new SqlCommand(), "SELECT TOP 8 s.*,c.* FROM Samples s LEFT JOIN Categories c on c.CatID=s.CatID ORDER BY SampleID DESC");
}
************** Default.cs ***** **************
**************Default.cs*******************
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) BindSamples();
}
private void BindSamples()
{
DataTable dt = Sample.GetNewSamplesWithCategories();
rptSamples.DataSource = dt;
rptSamples.DataBind();
}
我的尝试:
我从ftp服务器下载代码和.bak文件并在我的本地机器数据库[React2Media]中恢复它,我在aspx页面中更改了连接字符串和数据库名称。现在我坚持上述错误。当我跟踪堆栈跟踪时,数据库中没有Sample表。我已粘贴上面的必要代码,并检查类别表是否存在,但没有样本表。请帮助解决缺少的内容,添加什么内容,因为我刚接触.net。
What I have tried:
I downloded the code and .bak file from ftp server and restored it in my local machine database[React2Media] and I changed the connection string and database name in aspx page. Now I'am stuck with the above error. When I followed through the stack trace there was no 'Sample' table in the database. I've pasted the necessary code above and checked 'categories' table to be present but no 'sample' table. Please assist on what is missing, what to add on as I'am new to .net.
推荐答案
这篇关于Sqlexception(0x80131904):无效的对象名称'samples'。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!