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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Inherits System.Web.UI.Page vs. Inherits Entities.Modules.PortalModuleBaseInherits System.Web.UI.Page vs. Inherits Entities.Modules.PortalModuleBase
Previous
 
Next
New Post
9/19/2007 2:18 PM
 

This should be really easy for you all. But i'm lost and really need some help.

In the past, I've accessed data with "Inherits System.Web.UI.Page" using:

Dim rootWebConfig As System.Configuration.Configuration

rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(System.Configuration.ConfigurationManager.AppSettings("appName"))

Dim connString As System.Configuration.ConnectionStringSettings

connString = rootWebConfig.ConnectionStrings.ConnectionStrings("databaseName")

Dim g_sqlConn As New Data.SqlClient.SqlConnection

Dim strSQL As String

Dim retVal As Data.SqlClient.SqlDataReader

'Assign the connection string and open a connection to the database.

g_sqlConn.ConnectionString = connString.ConnectionString

g_sqlConn.Open()

'Prepare the SQL string which contains the name of the stored procedure

'that will return our data.

strSQL = "sp_storedprocedurename"

'Prepare the SQL command and execute the stored procedure.

Dim sqlCommand1 As Data.SqlClient.SqlCommand = New Data.SqlClient.SqlCommand(strSQL, g_sqlConn)

retVal = sqlCommand1.ExecuteReader()

'Check to make sure that rows have been returned (they should), if not exit gracefully leaving the drop down empty.

If retVal.HasRows = True Then

' code here


While retVal.Read


' code here

End While

End If

'Close the data reader and the data connection.

retVal.Close()

g_sqlConn.Close()

 

 Now, using "Inherits Entities.Modules.PortalModuleBase" that doesn't work because:


Dim g_sqlConn As New Data.SqlClient.SqlConnection

Dim strSQL As String

Dim retVal As Data.SqlClient.SqlDataReader

throws errors. It should be clear that I don't really fully understand the original code. My hope is that I can make a few adjustments (something along the lines of replacing Data.SqlClient.SqlDataReader with DotNetNuke.Data.SqlProvider) and voila! everything works. Probably not that simple.

Any thoughts?

 
New Post
9/19/2007 3:11 PM
 

So, now that i've revealed just how ignorant i am, i'll state what I'm trying to do. It should be easy, but I have 4 different references and they all treat data access differently and none seem to address my needs.

I've set up my stored procedures. I've modified the dal and bll files and have a working ObjectDataSource control that retreives row data and allows me to interact with the table via a gridview control.

Now, I want to use the column data from that table to build some HTML. I was trying to use a repeater with a datasource set to the ObjectDataSource mentioned above, but everything I read suggests that that is either not workable or a bad idea.

This has to be easy, I'm just lost in my reference books as to how to do it.

 
New Post
9/19/2007 4:15 PM
 

Perhaps System.Data.SqlClient.SqlConnection?

 
New Post
9/19/2007 5:17 PM
 

That's interesting. First, that did remove the squiggly lines (error highlights?), but the module now throws an error:

Error: HeroRotator is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at YourCompany.Modules.HeroRotator.ViewHeroRotator.LoadHero() at YourCompany.Modules.HeroRotator.ViewHeroRotator.Page_Load(Object sender, EventArgs e) --- End of inner exception stack trace ---

it appears to relate to this line:

g_sqlConn.ConnectionString = connString.ConnectionString

 
New Post
9/19/2007 6:40 PM
 

Previously, I called a method (LoadHero) on page load that ran the code. After using your suggestion, that errored out:

Error: HeroRotator is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at YourCompany.Modules.HeroRotator.ViewHeroRotator.LoadHero() at YourCompany.Modules.HeroRotator.ViewHeroRotator.Page_Load(Object sender, EventArgs e) --- End of inner exception stack trace ---

However, if I replace the call with the actual code I get a new error:

Error: HeroRotator is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: ExecuteReader: Connection property has not been initialized. ---> System.InvalidOperationException: ExecuteReader: Connection property has not been initialized. at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader() at YourCompany.Modules.HeroRotator.ViewHeroRotator.Page_Load(Object sender, EventArgs e) --- End of inner exception stack trace ---

Interesting?! Helpful? Thoughts?

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Inherits System.Web.UI.Page vs. Inherits Entities.Modules.PortalModuleBaseInherits System.Web.UI.Page vs. Inherits Entities.Modules.PortalModuleBase


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