Hello,
I have a simple module that uses one table (two columns). I need to create a one click installation module package. I have read some posts and came up with a small change. I added an SQL provider file to my zip package which adds the table. I also changed the sqlconnection in the ascx.vb file to the sql connection of the new site to which I need to install the package. I understand that this is not going to be a "one click" installation with the hardcoded connection but just wanted to have it work before I tackle that issue. The installation completed on the other site but after adding it to the site the module itself shows the following error. Keep in mind this is my own module, not the blog module which seems to have a bug related to this error:
Error: UserComments is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: The server tag is not well formed. ---> System.Web.HttpParseException: The server tag is not well formed. ---> System.Web.HttpException: The server tag is not well formed. at System.Web.UI.TemplateParser.ProcessError(String message) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath) at System.Web.UI.TemplateParser.Parse() at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType() at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at DotNetNuke.UI.ControlUtilities.LoadControl[T](TemplateControl containerControl, String ControlSrc) at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl() --- End of inner exception stack trace ---
My ascx file:
%@ Control Language="VB" AutoEventWireup="false" CodeFile="UserComments.ascx.vb" Inherits="DesktopModules_UserComments_UserComments" %>
<asp:Label ID="Label1" runat="server"
Text="Your comments are greatly appreciated"></asp:Label>
<p>
<asp:TextBox ID="TextBox1" runat="server" Height="192px" Width="483px"></asp:TextBox>
</p>
<p>
<asp:Button ID="Button1" runat="server" Text="Send" />
<asp:Label ID="Label2" runat="server" Text=" "></asp:Label>
</p>
<p>
<asp:Button ID="Button2" runat="server" Text="See all comments" />
</p>
<p>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="SqlConnection("data source = .\sql2008; Initial Catalog =dotnetnukedemo2; Integrated Security = True")"
SelectCommand="SELECT * FROM [dnn_usercomments]"></asp:SqlDataSource>
</p>
<p>
</p>
<asp:Panel ID="Panel1" runat="server" Height="229px" Visible="False">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1"
style="margin-top: 19px" BorderColor="Black" BorderStyle="None"
ForeColor="Black">
<Columns>
<asp:BoundField DataField="comment" HeaderText="comment"
SortExpression="comment" />
<asp:BoundField DataField="date" HeaderText="date" SortExpression="date" />
</Columns>
</asp:GridView>
</asp:Panel>
My ascx.vb file
Imports DotNetNuke.Entities.Modules
Imports System
Imports System.Data
Imports System.Data.SqlClient
Partial Class DesktopModules_UserComments_UserComments
Inherits PortalModuleBase
Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As New SqlConnection("data source = .\sql2008; Initial Catalog =dotnetnukedemo2; Integrated Security = True")
Dim comment As String
Dim commentdate As Date
Dim cmd As New SqlCommand
cmd.Connection = cn
comment = TextBox1.Text
commentdate = System.DateTime.Now
cn.Open()
cmd.Parameters.Add(New SqlParameter("Comment", comment))
cmd.Parameters.Add(New SqlParameter("Commentdate", commentdate))
cmd.CommandText = "INSERT INTO dnn_usercomments (comment, date) VALUES (@comment, @commentdate)"
cmd.ExecuteNonQuery()
cn.Close()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Panel1.Visible = True
Dim sqlresult As Object
Panel1.Visible = True
Dim cn As New SqlConnection("data source = .\sql2008; Initial Catalog =dotnetnukedemo2; Integrated Security = True")
Dim cmd As New SqlCommand
cmd.Connection = cn
cn.Open()
cmd.CommandText = "SELECT COUNT(*) AS RETURNCOUNT FROM dnn_usercomments"
sqlresult = cmd.ExecuteScalar
Dim count As Single = Convert.ToSingle(sqlresult)
Panel1.Height = 22 * count
cn.Close()
End Sub
End Class
My dnn file
<dotnetnuke type="Package" version="5.0">
<packages><package name="UserComments" type="Module" version="1.0.0">
<friendlyName>UserComments</friendlyName>
<description />
<owner>
<name>Jelena</name>
<organization>Corymb</organization>
<url />
<email>jelena.hazlehurst@usa.com</email>
</owner>
<license>The license for this package is not currently included within the installation file, please check with the vendor for full license details.</license>
<releaseNotes />
<components>
<component type="Script">
<scripts>
<script type="Install">
<name>01.00.00.SqlDataProvider</name>
<version>01.00.00</version>
</script>
</scripts>
</component>
<component type="Module">
<desktopModule>
<moduleName>UserComments</moduleName>
<foldername>UserComments</foldername>
<businessControllerClass />
<supportedFeatures />
<moduleDefinitions>
<moduleDefinition>
<friendlyName>UserComments</friendlyName>
<defaultCacheTime>0</defaultCacheTime>
<moduleControls>
<moduleControl>
<controlKey />
<controlSrc>DesktopModules/UserComments/UserComments.ascx</controlSrc>
<supportsPartialRendering>False</supportsPartialRendering>
<controlTitle />
<controlType>View</controlType>
<iconFile />
<helpUrl />
<viewOrder>0</viewOrder>
</moduleControl>
</moduleControls>
</moduleDefinition>
</moduleDefinitions>
</desktopModule>
</component>
<component type="File">
<files>
<basePath>DesktopModules\UserComments</basePath>
<file>
<name>UserComments.ascx</name>
</file>
<file>
<name>UserComments.ascx.vb</name>
</file>
</files>
</component>
</components>
</package></packages>
</dotnetnuke>
My sql provider file:
/****** Object: Table [dbo].[dnn_usercomments] Script Date: 04/30/2011 20:24:45 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[dnn_usercomments](
[comment] [text] NULL,
[date] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO