创建一个带有易于安装 sql 数据库的 dotnetnuke 包

发布于 2024-11-03 21:25:50 字数 156 浏览 4 评论 0原文

我对 dotnetnuke 和 asp.net 都是新手。我需要创建一个易于安装在不同 DNN 站点上的模块包。问题是需要手动添加 SQL 表和其他数据库对象。我希望在部署包时自动添加它们。正如我所说,我对这一切都很陌生,一步一步的解释会非常有帮助。

谢谢,

耶莱娜

I am new to dotnetnuke and asp.net altogether. I need to create a module package that is easy to install on a different DNN site. The problem is that SQL tables and other database objects need to be added manually. I would like them to be added automatically when the package is deployed. As I said I am new to all this and a step by step explanation would be very helpful.

Thanks,

Jelena

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一场信仰旅途 2024-11-10 21:25:50

这是由 SqlDataProvider 文件处理的。

请注意,当您在 VS2010(或 VS2008)中创建 DotNetNuke 编译模块项目时,您最终会得到三个这样的文件,其中两个是这里关注的(我认为)

  • 时执行
  • 01.00.00.SqlDataProvider 在模块安装Uninstall.SqlDataProvider 在 DNN 清单文件中的卸载注释上运行

,有指向这些 SqqDataProvider 文件的条目:

    <file>
      <name>01.00.00.SqlDataProvider</name>
    </file>
    <file>
      <name>Uninstall.SqlDataProvider</name>
    </file>

另请注意,在清单中文件中,版本号与安装程序 SQL 文件上的前缀相对应:

<version>01.00.00</version>

最后,您将 DNN 模块打包到 .zip 文件中。我无法理解确切的结构,但 DNNCreative 和下面引用的书籍提供了大量信息。

获得可部署的 .zip 文件后,您可以像从 SnowCovered 购买的任何其他模块一样安装它。

我的建议是执行以下操作:

我使用了这两个资源,发现它们非常有用

This is handled by SqlDataProvider files.

Note, that when you create a DotNetNuke Compiled Module project in VS2010 (or VS2008), you end up with three such files, two of which are of concern here (I think)

  • 01.00.00.SqlDataProvider is executed upon Module Installation
  • Uninstall.SqlDataProvider is run upon Uninstallation

Note in your DNN Manifest file, there are entries pointing to these SqqDataProvider files:

    <file>
      <name>01.00.00.SqlDataProvider</name>
    </file>
    <file>
      <name>Uninstall.SqlDataProvider</name>
    </file>

Also note, in the manifest file, that the version number corresponds to the prefix on the installer SQL file:

<version>01.00.00</version>

Finally, you will package your DNN Module into a .zip file. The exact structure evades me, but DNNCreative and the book referenced below have plenty of info.

Once you have the deployable .zip file, you install it just like any other module you might buy off SnowCovered.

My Suggestion is to do the following

I used both resources and found them very useful

幽梦紫曦~ 2024-11-10 21:25:50

好吧,我已经解决了这个问题,并想与那些可能仍在挣扎的人分享。创建包后,您需要将其解压缩并编辑一些文件。查看包中的 .dnn 文件。正如 Hamlin 指出的那样,您需要添加将执行 SQL 脚本并创建表、存储过程和其他数据库对象的脚本(而不是文件)。这是我添加到 dnn 文件中的代码部分。它被添加到组件标签中。

  <components>
     <component type="Script">
         <scripts> 
            <basePath>DesktopModules\UserComments</basePath>
            <script type="Install">
            <name>05.02.05.SqlDataProvider</name> 
            <version>05.02.05</version>
            </script>

             <script type="uninstall"> 
            <name>uninstall.sqldataprovider</name> 
            <version>05.02.05</version>     
            </script>
         </scripts>
     </component>
        <component type="Module"> 

您需要在其中输入路径、文件类型、文件名和版本。然后,您需要创建清单中指定的数据提供程序文件。我使用 {databaseOwner} 和 {objectQualifier} 来确保新的数据库对象符合它们将安装的服务器。这些是区分大小写的,所以要小心,否则你会得到错误。我的 dataprovider 文件如下所示:

05.02.05.sqldataprovider

ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE {databaseOwner}{objectQualifier}usercomments(
    [moduleid] [int] NULL,
    [comment] [text] NULL,
    [date] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

create procedure {databaseOwner}sp_viewcomments 
@moduleid int
AS
BEGIN
SET NOCOUNT ON 
    SELECT moduleid, comment, date from {objectQualifier}usercomments where   moduleid=@moduleid
end
go

create PROCEDURE {databaseOwner}sp_usercommentsinsert 
@moduleid int,
@comment text,
@commentdate datetime
AS
BEGIN
SET NOCOUNT ON;
    insert into {databaseOwner}{objectQualifier}usercomments (moduleid, comment, date) values (@moduleid, @comment, @commentdate)  
END
go

create PROCEDURE {databasOwner}sp_countcomments
@moduleid int
As
begin
    SELECT count(*) from {databaseOwner}{objectQualifier}usercomments where moduleid=@moduleid
end
go

uninstall.sqldataprovider

DROP TABLE      {databaseOwner}{objectQualifier}usercomments 
GO

drop procedure {databaseOwner}sp_usercommentsinsert  
GO

drop procedure {databaseOwner}sp_viewcomments 
GO

drop procedure {databaseOwner}sp_countcomments 
go

确保 sqlconnections 适合新站点,并根据需要在包含连接的文件中进行更改(在我的例子中,我将它们放在 vb ascx 中) .vb 和 ascx 文件)。我使用此代码从 web.config 文件中提取信息并使连接适合任何站点。

vb 文件:

 Dim cn As New SqlConnection(ConfigurationManager.ConnectionStrings("sitesqlserver").ConnectionString) 

ascx 文件:

ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>"  

然后将所有文件(包括新的 dataprovider 文件)打包到 zip 文件中,然后就可以开始了。

O.K. I have gotten through this and would like to share with those who may be struggling still. Once you create a package you need to unzip it and edit some files. Take a look at the .dnn file in your package. There, as Hamlin pointed out, you need to add the SCRIPTS (not files) that will execute SQL scripts and create tables, stored procedures and other database objects. Here is the portion of the code I added to the dnn file. It is added to the components tag.

  <components>
     <component type="Script">
         <scripts> 
            <basePath>DesktopModules\UserComments</basePath>
            <script type="Install">
            <name>05.02.05.SqlDataProvider</name> 
            <version>05.02.05</version>
            </script>

             <script type="uninstall"> 
            <name>uninstall.sqldataprovider</name> 
            <version>05.02.05</version>     
            </script>
         </scripts>
     </component>
        <component type="Module"> 

There you need to put in the paths, file types, file names and versions. Then you need to create the dataprovider files you indicated in the manifest. I used the {databaseOwner} and {objectQualifier} to make sure the new database objects comply with the server they will be installed on. Those are case sensitive so be careful, otherwise you will be getting errors. Here is what my dataprovider files look like:

05.02.05.sqldataprovider

ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE {databaseOwner}{objectQualifier}usercomments(
    [moduleid] [int] NULL,
    [comment] [text] NULL,
    [date] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

create procedure {databaseOwner}sp_viewcomments 
@moduleid int
AS
BEGIN
SET NOCOUNT ON 
    SELECT moduleid, comment, date from {objectQualifier}usercomments where   moduleid=@moduleid
end
go

create PROCEDURE {databaseOwner}sp_usercommentsinsert 
@moduleid int,
@comment text,
@commentdate datetime
AS
BEGIN
SET NOCOUNT ON;
    insert into {databaseOwner}{objectQualifier}usercomments (moduleid, comment, date) values (@moduleid, @comment, @commentdate)  
END
go

create PROCEDURE {databasOwner}sp_countcomments
@moduleid int
As
begin
    SELECT count(*) from {databaseOwner}{objectQualifier}usercomments where moduleid=@moduleid
end
go

uninstall.sqldataprovider

DROP TABLE      {databaseOwner}{objectQualifier}usercomments 
GO

drop procedure {databaseOwner}sp_usercommentsinsert  
GO

drop procedure {databaseOwner}sp_viewcomments 
GO

drop procedure {databaseOwner}sp_countcomments 
go

Make sure that the sqlconnections are appropriate for the new site and make changes if necessary in those files that contain the connections (in my case I had them in vb ascx.vb and ascx fle). I used this code to pull the information from the web.config file and make the connection appropriate for any site.

vb file:

 Dim cn As New SqlConnection(ConfigurationManager.ConnectionStrings("sitesqlserver").ConnectionString) 

ascx file:

ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>"  

Then package all the files including the new dataprovider files into a zip file and you should be good to go.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文