Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
error details:
C#
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*****************
C#
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*****************
C#
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*******************
C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) BindSamples();
    }
    private void BindSamples()
    {
        DataTable dt = Sample.GetNewSamplesWithCategories();
        rptSamples.DataSource = dt;
        rptSamples.DataBind();
    }


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.
Posted
Updated 25-Oct-16 0:35am
Comments
Suvendu Shekhar Giri 25-Oct-16 5:35am    
SELECT TOP 8 s.*,c.* FROM Samples s LEFT JOIN Categories c on c.CatID=s.CatID ORDER BY SampleID DESC

As you have no "Samples" table in DB so it will not be able to find it and give the same error.

What you want here, querying from a table that does't exist?
Amith 12807185 25-Oct-16 6:45am    
I just wanted to know my understanding is correct on this since the code was given to review and learn
According to your query, "Samples" table is needed. Create that, if not present.
Amith 12807185 25-Oct-16 6:47am    
yea it's not there, just wanted to double check on that.

1 solution

Check your table names: you probably called it "Sample" rather than "Samples".
 
Share this answer
 
Comments
Amith 12807185 25-Oct-16 6:47am    
I searched entire database wasn't there any.
As this is my first development work, I am given the code for review purpose and learn.
Since yesterday I'am rectifying errors one by one now I'am stuck here. I just wanted
to know my understanding correct on this and there cannot be done anything if
there is no table.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900