I know public modules should use/create tables in the DotNetNuke database, but I'm developing some internal modules and would like to know the CORRECT way to add connections to ohter servers/databases and how to access. Any examples out there?
It's even better than what Hans-Peter says. You can also access the DNN database any way you like. What I think HP meant to say was 'if you don't like the way DNN accesses the DNN database then.... etc.'.
Basically if you know how to access data from ASP.NET (using ADO.NET, DAAB, COM ADO, xml, whatever) you can use it in DNN. Nothing forces you to use the provider model. Of course if you intend to write modules for distribution it makes sense to use standard
data access methods but even then it's not required in any way.
SquadEngine for game squad and clan hosting
GravityPoint for all other group portal hosting
TungstenTech: DNN Site
I'd like to use the DNN data provider to access my other databases.
I've done ADO.NET work...But would like to stay as much in the framework
as possible (IE...Use datacacheing and stuff) But I haven't done any DNN
Data access work (just starting into module development)...
So back to my original question...Are there some examples out there?
And can I use the DNN data providers to access other databases?
Sorry for my ignorance guys,
Any help would be appreciated,
The default database provider has a RunQuery method, so if you want to access the current DNN database use something like:
DataProvider.Instance.RunQuery(QueryText)
If you want to access outside of your database, what you can do is write your own method for your module, and create a method that takes QueryText and an optional ConnectionString. If the ConnectionString is empty, use the method above to get at the current
database, otherwise open a new connection using the passed ConnectionString and execute using it.
I have used something like this before:
Public Class Query Public Shared Function RetrieveData(ByVal QueryText As String, Optional ByVal ConnectionString As String = "") As DataSet
If ConnectionString = "" Then Return DataProvider.Instance.RunQuery(QueryText) Else Dim ds As DataSet Dim cn As OleDb.OleDbConnection = New OleDb.OleDbConnection(ConnectionString) Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(QueryText, cn) cn.Open() Dim tr As OleDb.OleDbTransaction = cn.BeginTransaction cmd.CommandTimeout = 300 ' change to 5 minutes cmd.Transaction = tr Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(cmd) ds = New DataSet da.Fill(ds) tr.Commit() cn.Close() Return ds End If End Function End Class
None
0 Points
7 Posts
Example of Accessing OTHER SQL Servers
Apr 13, 2005 10:19 AM|ShaneHamlin|LINK
I know public modules should use/create tables in the DotNetNuke database, but I'm developing some internal modules and would like to know the CORRECT way to add connections to ohter servers/databases and how to access. Any examples out there?
Thanks soooo much in advance for your help guys!
None
0 Points
560 Posts
Re: Example of Accessing OTHER SQL Servers
Apr 13, 2005 11:35 AM|SchelianHP|LINK
If you don't like to use the dnn database you can use any way you like to access any database you like.
Hans-Peter
DNNPortal German DotNetNuke Community
None
0 Points
565 Posts
Re: Example of Accessing OTHER SQL Servers
Apr 13, 2005 08:24 PM|Nocturnal|LINK
Basically if you know how to access data from ASP.NET (using ADO.NET, DAAB, COM ADO, xml, whatever) you can use it in DNN. Nothing forces you to use the provider model. Of course if you intend to write modules for distribution it makes sense to use standard data access methods but even then it's not required in any way.
GravityPoint for all other group portal hosting
TungstenTech: DNN Site
None
0 Points
7 Posts
Re: Example of Accessing OTHER SQL Servers
Apr 14, 2005 08:48 AM|ShaneHamlin|LINK
Thanks for the info...
I'd like to use the DNN data provider to access my other databases.
I've done ADO.NET work...But would like to stay as much in the framework
as possible (IE...Use datacacheing and stuff) But I haven't done any DNN
Data access work (just starting into module development)...
So back to my original question...Are there some examples out there?
And can I use the DNN data providers to access other databases?
Sorry for my ignorance guys,
Any help would be appreciated,
Shane
Member
10 Points
153 Posts
Re: Example of Accessing OTHER SQL Servers
Apr 14, 2005 09:12 AM|dnnstuff|LINK
The default database provider has a RunQuery method, so if you want to access the current DNN database use something like:
DataProvider.Instance.RunQuery(QueryText)
If you want to access outside of your database, what you can do is write your own method for your module, and create a method that takes QueryText and an optional ConnectionString. If the ConnectionString is empty, use the method above to get at the current database, otherwise open a new connection using the passed ConnectionString and execute using it.
I have used something like this before:
Available DotNetNuke modules - SQLView, CSSInclude, Aggregator - Tabbed Modules, Module Rotator
http://www.dnnstuff.com,
Member
10 Points
331 Posts
Re: Example of Accessing OTHER SQL Servers
Apr 14, 2005 11:50 AM|PScarlett|LINK
For a discussion on alternate data sources check out this thread http://forums.asp.net/ShowPost.aspx?PostID=855338
Paul.
www.tressleworks.ca
www.tz3p9v.ca