Here is my sqldataprovider. Am I doing anything wrong?
/************************************************************/
/***** 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}MyCompany_MyModule]') and OBJECTPROPERTY(id, N'IsTable') = 1)
BEGIN
CREATE TABLE {databaseOwner}[{objectQualifier}MyCompany_MyModule]
(
[ModuleID] [int] NOT NULL,
[ItemID] [int] NOT NULL IDENTITY(1, 1),
[Content] [ntext] NOT NULL,
[CreatedByUser] [int] NOT NULL,
[CreatedDate] [datetime] NOT NULL
)
ALTER TABLE {databaseOwner}[{objectQualifier}MyCompany_MyModule] ADD CONSTRAINT [PK_{objectQualifier}MyCompany_MyModule] PRIMARY KEY CLUSTERED ([ItemID])
CREATE NONCLUSTERED INDEX [IX_{objectQualifier}MyCompany_MyModule] ON {databaseOwner}[{objectQualifier}MyCompany_MyModule] ([ModuleID])
ALTER TABLE {databaseOwner}[{objectQualifier}MyCompany_MyModule] WITH NOCHECK ADD CONSTRAINT [FK_{objectQualifier}MyCompany_MyModule_{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}MyCompany_GetMyModules]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure {databaseOwner}{objectQualifier}MyCompany_GetMyModules
GO
if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}MyCompany_GetMyModule]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure {databaseOwner}{objectQualifier}MyCompany_GetMyModule
GO
if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}MyCompany_AddMyModule]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure {databaseOwner}{objectQualifier}MyCompany_AddMyModule
GO
if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}MyCompany_UpdateMyModule]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure {databaseOwner}{objectQualifier}MyCompany_UpdateMyModule
GO
if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}MyCompany_DeleteMyModule]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure {databaseOwner}{objectQualifier}MyCompany_DeleteMyModule
GO
/** Create Stored Procedures **/
create procedure {databaseOwner}{objectQualifier}MyCompany_GetMyModules
@ModuleId int
as
select ModuleId,
ItemId,
Content,
CreatedByUser,
{objectQualifier}MyCompany_MyModule.CreatedDate
from {objectQualifier}MyCompany_MyModule with (nolock)
left outer join {objectQualifier}Users on {objectQualifier}MyCompany_MyModule.CreatedByUser = {objectQualifier}Users.UserId
where ModuleId = @ModuleId
GO
create procedure {databaseOwner}{objectQualifier}MyCompany_GetMyModule
@ModuleId int,
@ItemId int
as
select ModuleId,
ItemId,
Content,
CreatedByUser,
{objectQualifier}MyCompany_MyModule.CreatedDate
from {objectQualifier}MyCompany_MyModule with (nolock)
left outer join {objectQualifier}Users on {objectQualifier}MyCompany_MyModule.CreatedByUser = {objectQualifier}Users.UserId
where ModuleId = @ModuleId
and ItemId = @ItemId
GO
create procedure {databaseOwner}{objectQualifier}MyCompany_AddMyModule
@ModuleId int,
@Content ntext,
@UserID int
as
insert into {objectQualifier}MyCompany_MyModule (
ModuleId,
Content,
CreatedByUser,
CreatedDate
)
values (
@ModuleId,
@Content,
@UserID,
getdate()
)
GO
create procedure {databaseOwner}{objectQualifier}MyCompany_UpdateMyModule
@ModuleId int,
@ItemId int,
@Content ntext,
@UserID int
as
update {objectQualifier}MyCompany_MyModule
set Content = @Content,
CreatedByUser = @UserID,
CreatedDate = getdate()
where ModuleId = @ModuleId
and ItemId = @ItemId
GO
create procedure {databaseOwner}{objectQualifier}MyCompany_DeleteMyModule
@ModuleId int,
@ItemId int
as
delete
from {objectQualifier}MyCompany_MyModule
where ModuleId = @ModuleId
and ItemId = @ItemId
GO
/************************************************************/
/***** SqlDataProvider *****/
/************************************************************/