Invalid Object Name Exception

Discussion in 'Databases' started by river, Feb 9, 2007.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi this is my first time trying to deploy a database and I've run into a bit of a problem.

    My Visual Web Developer Express application debugged without a glitch on my local machine but when I changed the connection string in the web.config file to point to the database on this server I started getting an Invalid Object Name Exception. How can I fix this?

    My application uses asp.net 2.0 and is written in C#.

    Thanks for any assistance you can give
     
  2. Notice it can't find the Manuscripts object?

    Did you deploy the objects in your apps \App_Code\ folder?
     
  3. Hi joel,


    Ok here it is. My code and webform are in two separate files so I will post both of them along with the error message.`


    ********************************


    using System;


    using System.Data;


    using System.Configuration;


    using System.Collections;


    using System.Web;


    using System.Web.Security;


    using System.Web.UI;


    using System.Web.UI.WebControls;


    using System.Web.UI.WebControls.WebParts;


    using System.Web.UI.HtmlControls;


    public partial class ManEntry : System.Web.UI.Page


    {


    protected void Page_Load(object sender, EventArgs e)


    {


    fvManEntry.ChangeMode(FormViewMode.Insert);


    }


    protected void btnSubmit_Click(object sender, EventArgs e)


    {


    TextBox titleText = (TextBox)fvManEntry.FindControl("txtTitle");


    DropDownList typeText = (DropDownList)fvManEntry.FindControl("ddlType");


    DropDownList statusText = (DropDownList)fvManEntry.FindControl("ddlStatus");


    TextBox mainIdeaText = (TextBox)fvManEntry.FindControl("txtMainIdea");


    TextBox publicationText = (TextBox)fvManEntry.FindControl("txtPublication");


    DropDownList sellStatusText = (DropDownList)fvManEntry.FindControl("ddlSellStatus");


    using (WLogTableAdapters.ManuscriptsTableAdapter adapter =


    new WLogTableAdapters.ManuscriptsTableAdapter())


    {


    string title = titleText.Text;


    string type = typeText.Text;


    string status = statusText.Text;


    string mainIdea = mainIdeaText.Text;


    string publication = publicationText.Text;


    string sellStatus = sellStatusText.Text;


    adapter.Insert(title, type, status, mainIdea, publication, sellStatus);


    Response.Redirect("Default.aspx");


    }


    }


    }


    **************************************


    <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ManEntry.aspx.cs" Inherits="ManEntry" Title="Manuscript Entry" %>


    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


    <asp:ObjectDataSource ID="objManEntry" runat="server" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetDataByID" TypeName="WLogTableAdapters.ManuscriptsTableAdapter" UpdateMethod="Update">


    <DeleteParameters>


    <asp:parameter Name="Original_ID" Type="Int32" />


    </DeleteParameters>


    <UpdateParameters>


    <asp:parameter Name="Title" Type="String" />


    <asp:parameter Name="Type" Type="String" />


    <asp:parameter Name="Status" Type="String" />


    <asp:parameter Name="MainIdea" Type="String" />


    <asp:parameter Name="Publication" Type="String" />


    <asp:parameter Name="SellStatus" Type="String" />


    <asp:parameter Name="Original_ID" Type="Int32" />


    </UpdateParameters>


    <InsertParameters>


    <asp:parameter Name="Title" Type="String" />


    <asp:parameter Name="Type" Type="String" />


    <asp:parameter Name="Status" Type="String" />


    <asp:parameter Name="MainIdea" Type="String" />


    <asp:parameter Name="Publication" Type="String" />


    <asp:parameter Name="SellStatus" Type="String" />


    </InsertParameters>


    </asp:ObjectDataSource>


    <center><h3>Enter Manuscript Data</h3>


    <asp:FormView ID="fvManEntry" DataSourceID="objManEntry" runat="server">


    <InsertItemTemplate>


    <p>Title <asp:TextBox ID="txtTitle" runat="server"></asp:TextBox></p>


    <p>


    Type


    <asp:DropDownList ID="ddlType" runat="server">


    <asp:ListItem Value="-1">Choose</asp:ListItem>


    <asp:ListItem>short</asp:ListItem>


    <asp:ListItem>novel</asp:ListItem>


    <asp:ListItem>poem</asp:ListItem>


    <asp:ListItem>song</asp:ListItem>


    <asp:ListItem>essay</asp:ListItem>


    <asp:ListItem>other</asp:ListItem>


    </asp:DropDownList>


    </p>


    <p>


    Status


    <asp:DropDownList ID="ddlStatus" runat="server">


    <asp:ListItem>future</asp:ListItem>


    <asp:ListItem>current</asp:ListItem>


    <asp:ListItem>finished</asp:ListItem>


    </asp:DropDownList>


    </p>


    <p>


    Main Idea


    <asp:TextBox ID="txtMainIdea" runat="server"></asp:TextBox>


    </p>


    <p>


    Publication


    <asp:TextBox ID="txtPublication" runat="server"></asp:TextBox>


    </p>


    <p>


    Sell Status


    <asp:DropDownList ID="ddlSellStatus" runat="server">


    <asp:ListItem>future</asp:ListItem>


    <asp:ListItem>pending</asp:ListItem>


    <asp:ListItem>Sold</asp:ListItem>





    </asp:DropDownList>


    </p>


    <asp:Button ID="btnSubmit" runat="server" Text="Submit" SkinID="buttons" OnClick="btnSubmit_Click" />


    </InsertItemTemplate>


    </asp:FormView></center>


    </asp:Content>





    *****************************


    Server Error in '/WritingRecord' Application.


    --------------------------------------------------------------------------------


    Invalid object name 'Manuscripts'.


    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.


    Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'Manuscripts'.


    Source Error:





    Line 1540: }


    Line 1541: try {


    Line 1542: int returnValue = this.Adapter.InsertCommand.ExecuteNonQuery();


    Line 1543: return returnValue;


    Line 1544: }





    Source File: c:\WINDOWS\microsoft.net\Framework\v2.0.50727\Temporary ASP.NET Files\writingrecord\1889c642\352bfe50\App_Code.wgrykkpo.2.cs Line: 1542


    Stack Trace:





    [SqlException (0x80131904): Invalid object name 'Manuscripts'.]


    System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857418


    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735030


    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188


    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838


    System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149


    System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886


    System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132


    System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415


    System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135


    WLogTableAdapters.ManuscriptsTableAdapter.Insert(String Title, String Type, String Status, String MainIdea, String Publication, String SellStatus) in c:\WINDOWS\microsoft.net\Framework\v2.0.50727\Temporary ASP.NET Files\writingrecord\1889c642\352bfe50\App_Code.wgrykkpo.2.cs:1542


    ManEntry.btnSubmit_Click(Object sender, EventArgs e) in e:\web\tecknowledg\htdocs\WritingRecord\ManEntry.aspx.cs:38


    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105


    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107


    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7


    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11


    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33


    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102








    --------------------------------------------------------------------------------


    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
     
  4. I uploaded everything to the server. I didn't do anything special to the .cs file in the App_Code folder. Is there something I need to do to it? Would it be easier to re-configure the object data source to point directly to the table adapterinstead of using the App_Code? Here is the file in the App_Code
    *************



    using System;


    using System.Data;


    using System.Configuration;


    using System.Web;


    using System.Web.Security;


    using System.Web.UI;


    using System.Web.UI.WebControls;


    using System.Web.UI.WebControls.WebParts;


    using System.Web.UI.HtmlControls;


    /// <summary>


    /// Summary description for ManDisplayMethods


    /// </summary>


    public class ManDisplayMethods


    {


    public WLog.ManuscriptsDataTable GetTitles()


    {


    using (WLogTableAdapters.ManuscriptsTableAdapter adapter


    = new WLogTableAdapters.ManuscriptsTableAdapter())


    {


    return adapter.GetTitles();


    }


    }





    public WLog.ManuscriptsDataTable GetTitlesByID()


    {


    using (WLogTableAdapters.ManuscriptsTableAdapter adapter


    = new WLogTableAdapters.ManuscriptsTableAdapter())


    {


    return adapter.GetTitlesByID();


    }


    }





    }





    **********************************


    As you can see these are just methods from the table adapter I use so the object data sources will be shorter..
     
  5. Are you sure you uploaded everything?
    I might be missing something but I can't understand why the object can't be found since you have created a valid TableAdapter.
    That part is typically pretty simple.
     
  6. I uploaded the entire folder containing the application using WS_FTP then attached the mdf file to the server. The mdf file has been detached, attached, backed up and restored. Is there a way I can view the actual database on the server so that I can see what's there? Also I noticed Visual Web Developer Express created an ldf file in the App_Data folder. Is that significant?
     
  7. Now I see...
    Looks like you'll need to get a response from the DASP guys on this.
    ASupport ticket from your Control Panel would be a good idea.

    The ldf database filescreated by the express products are logs of transactions.
    They don't contain the data schema but they are a match set for the parent MDF.

    I'm not sure but I think you'll need to attach that database to an actual server, or use an Access DB.
    But that's what you should ask Support. [​IMG]
     
  8. Are you saying that the problem is the .ldf file? They had sent me to you thining it was a coding problem. Please tell me exactly what you see as the problem so that when I go back to them I will know what to say.

    Thanx
     
  9. It's not for me to say, rather the Support team, that you need a SQL Server addon for your DASP account.
    If you don't want to add a SQL Server option you'll need to use an Access database instead.
     
  10. Ok I noticed this line "Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'Manuscripts'."


    This line tells me you're trying to connect to a sql server or sql express. The invalid object name 'Manuscripts' is searching for a SQL object, like a table, view, stored procedure, etc. So you don't have to worry about your code not being uploaded properlyor a library not in the bin, this is issueis with the database.


    The fact that you're talking about an 'ldf' file tells me you are either talking about sql express or access. I'm going to guess sql express.


    With both sql express and access the 'ldf' file is just a 'lock' file. If you're not using the database, this file can be safely removed.


    Sql express will not run on DASP, as sql express was never meant to be run in a production environment.


    I recommend you upgrade to either sql 2000 or sql 2005. We have some nice tools that will help you upsize your database from sql express to sql server.





    If any of my assumptions are wrong, please let me know and I'll try to help you solve your problems :)





    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  11. Bruce

    Bruce DiscountASP.NET Staff

    A minor clarification.


    ldf file for SQL is not a lock file but rather transaction log file. If you detech your database properly, all the transactions should be commited and the log should not contain much useful information.


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page