A class that holds a SqlDatabase connection, creates the connection
using a conenction string found in the web.config file and exposes it
via a property -- viola...

Imports System.Data.SqlClient
Imports Systen.Configuration

Public Class DataBaseGoodies
       Private mSqlConn as SqlConnection

       Public Sub New()
           mSqlConn = new
SqlConnection(ConfigurationManager.AppSettings("connstring"))
       End Sub

       Public ReadOnly Property DBConnection as SqlConnection
            Get
               Return mSqlConn
          End Get
       End Property
End Class

Note that there is probably a sexier way to do this in 2.0. I noticed
a ConnectionString property on the ConfigurationManager, but haven't
had time to investigate it yet.

Also note, I would write a class that did all my database work
internally and simply returned DataSets or DataTables.

On 1/25/06, shyms05 <[EMAIL PROTECTED]> wrote:
> Hi to all,
>
> well am new to asp.net 2.0.i want to know how to create a class n
> module, so as to store database connection.
>
> plz help
>
> thx u all in advance
>
> hope to hear from u
>
> regards
> shyms
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>


--
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNet2/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to