Last post Apr 14, 2005 11:50 AM by PScarlett
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!
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.
Apr 13, 2005 08:24 PM|Nocturnal|LINK
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,
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:
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
Apr 14, 2005 11:50 AM|PScarlett|LINK
For a discussion on alternate data sources check out this thread