Hi,
I am new to DNN module development and trying to create a simple module which will show a set of data from an external database (nothing fancy just a plain select statement - database server is using a public IP / not local)
I have created a standard asp.net page which does what I want – A datagrid control created by dragging and dropping the table I want to show from the database explorer panel in visual studio onto a .aspx page.
This approach also works fine in a DNN module running on my local “test” DNN install (in the view.ascx page) however, when I install the .zip package onto my live website I get an error:
“Error: ExampleModule is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException: The connection name 'DatabaseConnectionString1' was not found in the applications configuration or the connection string is empty.”
From Googling around I think the answer might be in creating the connection string in the web.config file? I have tried various different combinations of this but nothing seems to work for me. Would anyone be kind enough to point me in the right direction please. My code so far is below:
<
asp:GridView
ID
=
"GridView1"
runat
=
"server"
AutoGenerateColumns
=
"False"
DataKeyNames
=
"ShopID"
DataSourceID
=
"SqlDataSource1"
EmptyDataText
=
"There are no data records to display."
>
<
Columns
>
<
asp:BoundField
DataField
=
"ShopID"
HeaderText
=
"ShopID"
ReadOnly
=
"True"
SortExpression
=
"ShopID"
/>
<
asp:BoundField
DataField
=
"Town"
HeaderText
=
"Town"
SortExpression
=
"Town"
/>
<
asp:BoundField
DataField
=
"PostCode"
HeaderText
=
"PostCode"
SortExpression
=
"PostCode"
/>
<
asp:BoundField
DataField
=
"PhotoURL"
HeaderText
=
"PhotoURL"
SortExpression
=
"PhotoURL"
/>
</
Columns
>
</
asp:GridView
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString1 %>" ProviderName="<%$ ConnectionStrings:DatabaseConnectionString1.ProviderName %>" SelectCommand="SELECT [ShopID], [Town], [PostCode], [PhotoURL] FROM [Shop]">
</
asp:SqlDataSource
>
Many Thanks
James