Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
Previous
 
Next
New Post
2/18/2009 4:58 PM
 

I am getting the following error The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION. when I execute SQL that contains BEGIN TRANSACTION and COMMIT. The query executes without problems if I execute it directly on the database but if I use the same code in a module install package or run it in the SQL module in a DNN web I get the error. The query in the example below was generated automatically from SQL server management studio. Is there some way to work arround this problem?

Example of a query that results in the error:

/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.Lists
    DROP CONSTRAINT DF_Lists_ParentID
GO
ALTER TABLE dbo.Lists
    DROP CONSTRAINT DF_Lists_Level
GO
ALTER TABLE dbo.Lists
    DROP CONSTRAINT DF_Lists_SortOrder
GO
ALTER TABLE dbo.Lists
    DROP CONSTRAINT DF_Lists_DefinitionID
GO
ALTER TABLE dbo.Lists
    DROP CONSTRAINT DF_Lists_PortalID
GO
ALTER TABLE dbo.Lists
    DROP CONSTRAINT DF_Lists_SystemList
GO
CREATE TABLE dbo.Tmp_Lists
    (
    EntryID int NOT NULL IDENTITY (1, 1),
    ListName nvarchar(55) NOT NULL,
    Value nvarchar(100) NOT NULL,
    Text nvarchar(150) NOT NULL,
    ParentID int NOT NULL,
    [Level] int NOT NULL,
    SortOrder int NOT NULL,
    DefinitionID int NOT NULL,
    Description nvarchar(500) NULL,
    PortalID int NOT NULL,
    SystemList bit NOT NULL
    )  ON [PRIMARY]
GO
ALTER TABLE dbo.Tmp_Lists ADD CONSTRAINT
    DF_Lists_ParentID DEFAULT ((0)) FOR ParentID
GO
ALTER TABLE dbo.Tmp_Lists ADD CONSTRAINT
    DF_Lists_Level DEFAULT ((0)) FOR [Level]
GO
ALTER TABLE dbo.Tmp_Lists ADD CONSTRAINT
    DF_Lists_SortOrder DEFAULT ((0)) FOR SortOrder
GO
ALTER TABLE dbo.Tmp_Lists ADD CONSTRAINT
    DF_Lists_DefinitionID DEFAULT ((0)) FOR DefinitionID
GO
ALTER TABLE dbo.Tmp_Lists ADD CONSTRAINT
    DF_Lists_PortalID DEFAULT ((-1)) FOR PortalID
GO
ALTER TABLE dbo.Tmp_Lists ADD CONSTRAINT
    DF_Lists_SystemList DEFAULT ((0)) FOR SystemList
GO
SET IDENTITY_INSERT dbo.Tmp_Lists ON
GO
IF EXISTS(SELECT * FROM dbo.Lists)
     EXEC('INSERT INTO dbo.Tmp_Lists (EntryID, ListName, Value, Text, ParentID, [Level], SortOrder, DefinitionID, Description, PortalID, SystemList)
        SELECT EntryID, ListName, Value, Text, ParentID, [Level], SortOrder, DefinitionID, Description, PortalID, SystemList FROM dbo.Lists WITH (HOLDLOCK TABLOCKX)')
GO
SET IDENTITY_INSERT dbo.Tmp_Lists OFF
GO
DROP TABLE dbo.Lists
GO
EXECUTE sp_rename N'dbo.Tmp_Lists', N'Lists', 'OBJECT'
GO
ALTER TABLE dbo.Lists ADD CONSTRAINT
    PK_Lists PRIMARY KEY CLUSTERED
    (
    ListName,
    Value,
    Text,
    ParentID
    ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO
COMMIT

 
New Post
2/18/2009 7:04 PM
 

SQL Server has a mode known as "auto-commit" (http://msdn.microsoft.com/en-us/library/aa213069(SQL.80).aspx ) . This is the default setting, and it means that every statement is automatically committed after being processed. Effectively this means you do not have to create explicit TRANSACTION and COMMIT operations.

As your sql script has these explicit operations it looks like you're generating on one server (with auto-commit disabled) and deployed to another server (with auto-commit enabled) the 2nd server get's to the end and has nothing to commit as each block has been committed as it went along.

Cathal


Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
2/19/2009 12:07 PM
 

Thank you for your reply. I forgot to mention this is on the same server and the same database. I have also tried to remove the transaction anc commit operations but then I get an error stating the insert failed because Identity_insert is ON so it seems it does not execute SET IDENTITY_INSERT ON.

 
New Post
2/19/2009 12:15 PM
 

When DNN runs SQL as a script, it splits the script at each GO statement, and executes each chunk of SQL as a separate command.  This means that if you have a GO statement between your BEGIN TRANS and COMMIT statements, then they will be in separate query batches, and not related to each other.  If possible, you can remove the GO statements.  Otherwise, there isn't much of a way that I know of to run your SQL with transactions through DNN.

Hope that helps,


Brian Dukes
Engage Software
St. Louis, MO
866-907-4002
DNN partner specializing in custom, enterprise DNN development.
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out