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

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsProvidersProvidersIncorrect syntax error in 01.00.00.SqlDataProviderIncorrect syntax error in 01.00.00.SqlDataProvider
Previous
 
Next
New Post
7/20/2010 10:33 PM
 
Hello all..

I'm following along in the Professional DotNetNuke Module Programming book and I'm at the section where I update the 01.00.00.SqlDataProvider file.  After completing the script I tested in SSMS by parsing it and I come up with several errors, Incorrect syntax near '{'., which appear to be mostly assoicated to the {databaseOwner} tag.  I figured I missed something or the copy from the .pdf was not transfering over correctly so I when ahead and downloaded the code from the Wrox book site and that script gives me the same errors.  I'm not sure what I'm missing or even if the script will error during the installation of the module but I wanted to see if anyone had any thoughts.

Code:

/************************************************************/
/*****              SqlDataProvider                     *****/
/*****                                                  *****/
/*****                                                  *****/
/***** Note: To manually execute this script you must   *****/
/*****       perform a search and replace operation     *****/
/*****       for {databaseOwner} and {objectQualifier}  *****/
/*****                                                  *****/
/************************************************************/

/** Create Table **/

if not exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_Guestbook]') and OBJECTPROPERTY(id, N'IsTable') = 1)
 BEGIN
  CREATE TABLE {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_Guestbook]
  (
   [ModuleId] [int] NOT NULL,
   [EntryId] [int] NOT NULL IDENTITY(1, 1),
   [SubmitterName] nvarchar(255) NOT NULL,
   [SubmitterWebsite] nvarchar(255),
   [SubmitterComment] ntext,
   [SubmissionDate] DateTime NOT NULL,
   [IsApproved] BIT NOT NULL
  )

  ALTER TABLE {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_Guestbook]
   ADD CONSTRAINT [PK_{objectQualifier}DNNModuleProgramming_CS_Guestbook]
    PRIMARY KEY CLUSTERED  ([EntryId])
    
  CREATE NONCLUSTERED INDEX [IX_{objectQualifier}DNNModuleProgramming_CS_Guestbook]
   ON {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_Guestbook]
    ([ModuleID])

  ALTER TABLE {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_Guestbook] WITH NOCHECK
   ADD CONSTRAINT [FK_{objectQualifier}DNNModuleProgramming_CS_Guestbook_{objectQualifier}Modules]
    FOREIGN KEY ([ModuleID])
     REFERENCES {databaseOwner}[{objectQualifier}Modules] 
      ([ModuleID]) ON DELETE CASCADE NOT FOR REPLICATION
 END
GO

/** Drop Existing Stored Procedures **/

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

/** Create Stored Procedures **/
CREATE PROCEDURE {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_InsertGuestbookEntry]
 @ModuleId INT,
 @SubmitterName NVARCHAR(255),
 @SubmitterWebsite NVARCHAR(255),
 @SubmitterComment NTEXT,
 @SubmissionDate DATETIME,
 @IsApproved BIT
AS
INSERT INTO {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_Guestbook]
 (ModuleId, SubmitterName, SubmitterWebsite, SubmitterComment, SubmissionDate, IsApproved)
 VALUES
 (@ModuleId, @SubmitterName, @SubmitterWebsite, @SubmitterComment, @SubmissionDate, @IsApproved)
 
GO

CREATE PROCEDURE {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_ApproveGuestbookEntry]
 @ModuleId INT,
 @EntryId INT
AS
UPDATE {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_Guestbook]
SET IsApproved = 1
WHERE ModuleId = @ModuleId
 AND EntryId = @EntryId
 
GO

CREATE PROCEDURE {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_DeleteGuestbookEntry]
 @ModuleId INT,
 @EntryId INT
AS
DELETE FROM {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_Guestbook]
WHERE ModuleId = @ModuleId
 AND EntryId = @EntryId
 
GO

CREATE PROCEDURE {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_GetApprovedEntries]
 @ModuleId INT
AS
SELECT
 ModuleId,
 EntryId,
 SubmitterName,
 SubmitterWebsite,
 SubmitterComment,
 SubmissionDate,
 IsApproved
FROM {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_Guestbook]
WHERE ModuleId = @ModuleId
 AND IsApproved = 1
ORDER BY SubmissionDate DESC

GO

CREATE PROCEDURE {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_GetAllEntries]
 @ModuleId INT
AS
SELECT
 ModuleId,
 EntryId,
 SubmitterName,
 SubmitterWebsite,
 SubmitterComment,
 SubmissionDate,
 IsApproved
FROM {databaseOwner}[{objectQualifier}DNNModuleProgramming_CS_Guestbook]
WHERE ModuleId = @ModuleId
ORDER BY SubmissionDate DESC

GO

/************************************************************/
/*****              SqlDataProvider                     *****/
/************************************************************/



Thanks,
Bob
 
New Post
7/21/2010 2:52 AM
 
Bob - you can't test the script in SSMS without doing a substitution for {objectQualifier} and {databaseOwner}

What happens when this script is run, is that it is pre-processed by the DNN script engine, and a text find/replace is done on {objectQualifier} - from the value in your web.config (dnn_ by default) and {databaseOwner} - again from your web.config, and probably dbo. in most cases.

There's two options if you want to check syntax:
1. do a find/replace on those items in ssms and then check syntax
2. run it in your Host->sql script box, which uses the script engine to do the substitution for you.

It's a slightly tricky/messy part of DNN Module development, but it is very important as it gives your module flexibility to run on a variety of sql server setups.  You should always prefix your objects with {databaseOwner}{objectQualifier} in the Sql, because all DNN installs tend to use a different combination depending on the adminsitrator, target environment and other factors.
 
New Post
7/21/2010 9:05 AM
 
Thanks Bruce..I do the find and replace and see what I come up with.

Bob
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsProvidersProvidersIncorrect syntax error in 01.00.00.SqlDataProviderIncorrect syntax error in 01.00.00.SqlDataProvider


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