DNN Blog

Aug 18

Posted by: Alec Whittington
8/18/2006  RssIcon

It was brought to my attention in the Links forum that you could not edit a link when the database owner was not set to 'dbo'. This was due to an issue with the 03.03.00 database scripts referencing {databaseOwner} when looking to see if the GetLink and GetLinks stored procedures existed already. Since the system tables are always owned by dbo, this caused the problem when looking for them by {databaseOwner}.SystemTableName.

To fix this issue in your installation, you will need to login as the host account (or any super user account) and go to Host -> SQL. You can copy and paste the code below as is and execute the sql statements. Thanks to Leupold and CShark for pointing this out.

Quick Fix solution
Execute the following lines of SQL against your database:

if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetLink]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 drop procedure {databaseOwner}{objectQualifier}GetLink
GO

if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetLinks]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 drop procedure {databaseOwner}{objectQualifier}GetLinks
GO

CREATE procedure {databaseOwner}{objectQualifier}GetLink

@ItemId   int,
@ModuleId int

as

select  {objectQualifier}Links.ItemId,
 {objectQualifier}Links.ModuleId,
 {objectQualifier}Links.Title,
 {objectQualifier}Links.URL,
        {objectQualifier}Links.ViewOrder,
        {objectQualifier}Links.Description,
        {objectQualifier}Links.CreatedByUser,
        {objectQualifier}Links.CreatedDate,
        {objectQualifier}UrlTracking.TrackClicks,
        {objectQualifier}UrlTracking.NewWindow
from    {objectQualifier}Links
left outer join {objectQualifier}UrlTracking on {objectQualifier}Links.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID
where  {objectQualifier}Links.ItemId = @ItemId
and    {objectQualifier}Links.ModuleId = @ModuleId

GO

CREATE procedure {databaseOwner}{objectQualifier}GetLinks

@ModuleId int

as

select {objectQualifier}Links.ItemId,
       {objectQualifier}Links.ModuleId,
       {objectQualifier}Links.CreatedByUser,
       {objectQualifier}Links.CreatedDate,
       {objectQualifier}Links.Title,
       {objectQualifier}Links.URL,
       {objectQualifier}Links.ViewOrder,
       {objectQualifier}Links.Description,
       {objectQualifier}UrlTracking.TrackClicks,
       {objectQualifier}UrlTracking.NewWindow
from   {objectQualifier}Links
left outer join {objectQualifier}UrlTracking on {objectQualifier}Links.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID
where  {objectQualifier}Links.ModuleId = @ModuleId
order by {objectQualifier}Links.ViewOrder, {objectQualifier}Links.Title

GO

Tags:
Categories:

17 comment(s) so far...


Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

Alex,
you do not need to replace {DatabaseOwner} and {ObjectQualifier} if you log in as host and execute a script in host :: SQL menu item. I suggest providing the complete delete and recreate commands as continuous text for copy and paste.

By leupold on   9/8/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

Tip: you can run the scripts inside host->sql without changing {databaseOwner} or {objectqualifier}

By cshark on   9/8/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

Looking for answers I happened on this topic

I Just tried this on my test site hosted by 1 and 1.

First it gave me an error in the script

then I broke it down into individual actions and ran them individually.

The results were a perferctly working Links Module in DNN_4.3.4

thank you for solving one of my many problems.

By StageSlave on   9/8/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

This doesn't work with SQL 2005.

By jhecksel on   9/8/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

If you could elaborate on your statement that would help out. This was tested with both SQL2000 and SQL2005. If you are having an issue, please feel free to post it in the links forum and we will try to solve it.

By ncgoose on   9/8/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

I just installed a fresh version of DNN (4.3.5) and this is still broken. Why isn't it fixed in fresh installs and/or updates rather than making us go through this?

By royhiggs on   10/28/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

I get the following error when trying to run the above script:

System.Data.SqlClient.SqlException: 'CREATE/ALTER PROCEDURE' must be the first statement in a query batch. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL) at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions) if exists (select * from dbo.sysobjects where id = object_id(N'imsdnnuser.[GetLinks]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure imsdnnuser.GetLinks CREATE procedure imsdnnuser.GetLink @ItemId int, @ModuleId int as select Links.ItemId, Links.ModuleId, Links.Title, Links.URL, Links.ViewOrder, Links.Description, Links.CreatedByUser, Links.CreatedDate, UrlTracking.TrackClicks, UrlTracking.NewWindow from Links left outer join UrlTracking on Links.URL = UrlTracking.Url and UrlTracking.ModuleId = @ModuleID where Links.ItemId = @ItemId and Links.ModuleId = @ModuleId System.Data.SqlClient.SqlException: There is already an object named 'GetLinks' in the database. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL) at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions) CREATE procedure imsdnnuser.GetLinks @ModuleId int as select Links.ItemId, Links.ModuleId, Links.CreatedByUser, Links.CreatedDate, Links.Title, Links.URL, Links.ViewOrder, Links.Description, UrlTracking.TrackClicks, UrlTracking.NewWindow from Links left outer join UrlTracking on Links.URL = UrlTracking.Url and UrlTracking.ModuleId = @ModuleID where Links.ModuleId = @ModuleId order by Links.ViewOrder, Links.Title

By royhiggs on   10/28/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

I believe you are missing a GO after the second drop

I also had to remove {databaseOwner} and {objectqualifier} and put in my username.

By royhiggs on   10/28/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

It's odd that this would work for some and not for others. When I copy the entire script into my SQL window it does not work. Doing them in parts doesn't either. When I run this by clicking 'execute' it simply says "There is an error in your query!". When I check the 'script' box it is more verbose:

System.Data.SqlClient.SqlException: 'CREATE PROCEDURE' must be the first statement in a query batch. Must declare the variable '@ModuleID'. at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL) at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions) if exists (select * from dbo.sysobjects where id = object_id(N'sanderp_ttech.[GetLinks]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure sanderp_ttech.GetLinks CREATE procedure sanderp_ttech.GetLink @ItemId int, @ModuleId int as select Links.ItemId, Links.ModuleId, Links.Title, Links.URL, Links.ViewOrder, Links.Description, Links.CreatedByUser, Links.CreatedDate, UrlTracking.TrackClicks, UrlTracking.NewWindow from Links left outer join UrlTracking on Links.URL = UrlTracking.Url and UrlTracking.ModuleId = @ModuleID where Links.ItemId = @ItemId and Links.ModuleId = @ModuleId System.Data.SqlClient.SqlException: There is already an object named 'GetLinks' in the database. at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL) at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions) CREATE procedure sanderp_ttech.GetLinks @ModuleId int as select Links.ItemId, Links.ModuleId, Links.CreatedByUser, Links.CreatedDate, Links.Title, Links.URL, Links.ViewOrder, Links.Description, UrlTracking.TrackClicks, UrlTracking.NewWindow from Links left outer join UrlTracking on Links.URL = UrlTracking.Url and UrlTracking.ModuleId = @ModuleID where Links.ModuleId = @ModuleId order by Links.ViewOrder, Links.Title

By Nocturnal on   10/28/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

Royhiggs, you are correct. After adding that missing GO the statement completed. More importantly the edit functionality now works :)

Thanks!

By Nocturnal on   10/28/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

RoyHiggs, this issue was discovered after the last version came out. The newest version is in the release phase right now and once completed it will contain this fix. Project modules are independent of releases, hence the reason for this post.

By ncgoose on   10/29/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

I have a v4.3.5 portal, using SQL Server 2000, my database login is NOT dbo. I have tried running the above code (including adding the 'GO' statement after the second 'drop' statement. I keep getting an error; I tried executing each part separately as suggested and still get errors similar to this:

System.Data.SqlClient.SqlException: Line 23: Incorrect syntax near 'GO'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL) at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions) CREATE procedure portalp_ppndba.GetLink @ItemId int, @ModuleId int as select Links.ItemId, Links.ModuleId, Links.Title, Links.URL, Links.ViewOrder, Links.Description, Links.CreatedByUser, Links.CreatedDate, UrlTracking.TrackClicks, UrlTracking.NewWindow from Links left outer join UrlTracking on Links.URL = UrlTracking.Url and UrlTracking.ModuleId = @ModuleID where Links.ItemId = @ItemId and Links.ModuleId = @ModuleId GO

Any thoughts?
Thanks, Arden

By ardenfr on   11/10/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

Got it fixed I think....

I ran each section (excluding the 'GO' statement) separately. It seems to be working now. :)

Thanks,
Arden

By ardenfr on   11/10/2006

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

I've got Microsoft SQL Server 2005 - 9.00.2047.00, and the sql query doesn't work...
what cai i do to fix the bug ??
thanks

By blufishing on   1/11/2007

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

Follow the instructions of the comment above you. Run each statement separately and they should be fine.

By ncgoose on   1/11/2007

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

I have the same experience. I couldn't run the script at once and had to do it for each statement without the GO statement.

By martung on   3/8/2007

Re: FIX: [LNK-3916] - Cannot edit links when database owner is not 'dbo'

Before we upgraded to version 4.7 our links module was working. Now we are receiving the following errors on all the pages where the links module resides
An error has occurred.
Error: ITS Home Page Links is currently unavailable.

By melanyie on   11/13/2007
Attend A Webinar
Free Demo Site
Download DotNetNuke Professional Edition Trial
Have Someone Contact Me
Have Someone Contact Me
Charlotte DoDNN

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

Telerik JustCode Free
Exact Target Exec Alert
PowerDNN

Sponsors

DotNetNuke Corporation

DotNetNuke Corp. is the steward of the DotNetNuke open source project, the most widely adopted Web Content Management Platform for building web sites and web applications on Microsoft. Organizations use DotNetNuke to quickly develop and deploy interactive and dynamic web sites, intranets, extranets and web applications. The DotNetNuke platform is available in a free Community and subscription-based Professional and Enterprise Editions with an Elite Support option. DotNetNuke Corp. also operates the DotNetNuke Store where users purchase third party apps for the platform.