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?