Compartilhar via


Club Web Site Starter Kit: Invalid object name 'dbo.Events' or 'dbo.Locations' on default.aspx?

Club Site Starter Kit I'm preparing an article with some tips and tricks for making sure that your sites built with the Club Site Starter Kit and Personal Web Site Starter Kits for Visual Web Developer are cross-browser and cross-platform compatible.

In the process, I was struggling to host the Club Site Starter Kit in a "real world" shared hosting scenario, where I was connecting to SQL Server 2000 on another computer.  Everything was fine except for the main page of the site, default.aspx, which wouldn't display at all, and was causing an error: it couldn't find dbo.Event, or dbo.Location.  Invalid object name 'dbo.Events'. Invalid object name 'dbo.Locations'.

But both of those Tables existed in the database!  I had used a web-based SQL Server Admin tool to execute AddClub.sql to generate the tables for the Club Site.  I was naturally not logged in as dbo when I did so, but instead logged in using my login account name, which in my case was robburke. 

Here's the rub.  On default.aspx of the Club Site you'll find the following code, which assumes the tables are dbo-owned (as per my bold):

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ClubSiteDB %>"

SelectCommand="SELECT top 5 dbo. Events.id, dbo. Events.starttime, dbo. events.endtime, dbo. Events.title, dbo. Locations.title AS locationname FROM dbo. Events LEFT OUTER JOIN dbo. Locations ON dbo. Events.location = dbo. Locations.id WHERE (dbo. Events.starttime > GETDATE()) ORDER BY dbo. Events.starttime, dbo. events.id ">

</asp:SqlDataSource>

Look -- it's assuming that your tables were generated as dbo.  Getting rid of those prefixes worked for me.  I replaced it with this:

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ClubSiteDB %>"

SelectCommand="SELECT top 5 Events.id, Events.starttime, Events.endtime, Events.title, Locations.title AS locationname FROM Events LEFT OUTER JOIN Locations ON Events.location = Locations.id WHERE (Events.starttime > GETDATE()) ORDER BY Events.starttime, Events.id ">

</asp:SqlDataSource>

[Update: Similar code exists on Events_View.aspx and Events_Edit.aspx. Similarly search and remove "dbo." on those pages]

Hope that helps.

p.s. Correct the spelling mistake "Upcomming events" on Events_List.aspx while you're at it :)

Comments

  • Anonymous
    June 10, 2006
    Thanks for the dbo. help.  I inadvertently left out the events_view.aspx when updating the dbo. statements.  It was late and I googled for the error and hit your site first.  You sent me in the right direction and there they were, the dbo's, still in the events_view page.  I had updated the other pages in the beginning and overlooked the events_veiw.  Thanks to you for posting the info.

    junck