Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 10th, 2003, 08:06 PM
Registered User
 
Join Date: Oct 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default ADO.net + include files

Hello all

Up till now I've been creating my data connection within my .net pages or web service but would like to have one common place for all connections. How can this be accomplished.
 
Old December 11th, 2003, 02:08 PM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

use module component and public the variable

for your case:

Imports System.Data.SqlClient
Module Module1
    Public conn As SqlClient.SqlConnection

    'other code here your sub,function,class

End Module



Ahmed Ali
Software Developer
 
Old December 11th, 2003, 02:19 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Do you want a place to store the connection string? Are you looking to connect and maintain a single connection object that all parts of a page will use? Or do you want just centralize where/how you handle data? There are several different techniques depending on what your needs/desires are.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 12th, 2003, 03:43 AM
Registered User
 
Join Date: Dec 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

YOU CAN STORE THE CONNECTION STRING IN WEB.CONFIG FILE
EXAMPLE
<appSettings>
<add key="connectionString" value="server=IP;uid=USERNAME;pwd=***;database=DB" />
</appSettings>
AND YOU CAN CALL ON *.ASPX
...................
String cn=ConfigurationSettings.AppSettings["connectionString"];
                SqlConnection con =new SqlConnection(cn);






Similar Threads
Thread Thread Starter Forum Replies Last Post
include files b00gieman Classic ASP Basics 2 September 15th, 2007 10:22 AM
Include files tarang SQL Server 2000 1 July 18th, 2007 03:32 AM
"Include files" in VB.net mike_abc Pro VB.NET 2002/2003 3 February 24th, 2005 10:44 AM
Include Files jmss66 Classic ASP Basics 16 June 9th, 2004 10:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.