.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to declare a global connection object?

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
Following the post on declaring a global variable 'theDate' with a defined date format to be used across the web pages, I now encounter another tricky question: Is there a way to declare a global connection object so that I can avoid repeating the same statements (SqlConnection myconn = new SqlConnection(Class1.conn); myconn.Open();) in all the coding page that require a database connection? Thanks.

View Complete Post

More Related Resource Links

create and open global database connection object


Hi to everyone:

I`m trying to install the allinta cms software www.allinta.com, I have already create a MySQL Data Base, but when I try to launch my cmsadmin I t appears an error

Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'dbConnectionStr'

/cmsadmin/inc/db_connection.asp, line 75

IT  seems to be the Object Connection, could somebody help me to give the right code instruction please, I don´t have an idea on how to make it.

At this moment I opened in dreamweaver and it´s

Set objConn = Server.CreateObject("ADODB.Connection")

Which connection owns global temporary table?

Global temporary table exists over time of connection in which was created. I have several connections (sessions) open in management studio. How to check using sql statement, system views, etc... if global temporary table was created in current session?

trapping connection to remote object


I have a .net Remoting application.   I would like to do some tracking when connections are made.   Is there a way to interrogate connections being made to my remote object?

I have a singleton object, running as a service.   Basically when a ui connects I want to report back the state, and any pending messages.   So by looking at the connections I can keep a ptr to the next group of messages based on the client that connected.

Any insight into this would be a big help.



How to create global object and let everybody use it and several questions


i want to create a global object and my all users should be using it


here comes several questions


my web server is working like a web farm

there is hosted only 1 website but it has 12 w3wp.exe 

my session state is aspnet_state


so if i use global object how many times will it be created

i mean how does this thing works


also all users will be excessively accessing this object

would this cause problem ?


and how can i create this object and use it


also can this object be hash table


thank you

Database Connection is a managed object or unmanaged object??


Hi All,

            I am confused over this point that Connection with databse in ado.net is a managed object or unmanged object, from the past couple of years i was assuming that it is unmanged but  a post from MSDN says it is managed (Correct me if i am wrong :)), i am attching the link of that post herewith

please find  -----> :Note Do not call Close or Dispose.................... in the below Link


Thanks in Advance,


difference between object declare instantiation and initialization


Hi All,

             I am confused over these three terms,i know what is object declaration and initialization but confused over ojbect instantiation ,i am giving a example below what i understood :

Class ABC



Public static Void main()


ABC a   // Object declaration

 a = new ABC();   //Object initialization

//Then when and how instantiation comes into picture


Please provide any expale or informative links(if possible) while replying.



EF 4.1 connection string code first and object context


I have a question about using  an existing sql express(from a web host) with entity framework 4.1) and using an existing database  

Does this map directly using the following method. I posted this question in the msdn site and I really did not get a very good response so I hope someone helps out. my question Is what is the best way to map to an existing database on a web host    

  http://blogs.msdn.com/b/adonet/archive/2010/12/06/ef-feature-ctp5-code-first-walkthrough.aspx here is using a sql  default constructor

http://msdn.microsoft.com/en-us/library/bb896291.aspx you have to pre-configure entity framework here ....

I was wondering is this the way you do it using objectcontext

Public class  Blog context: Db context

public Blogcontext (Db connection connection)


Thinking about new C# method prototypes: object as dictionary

I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.

Global Exception Handling with ASP.NET

After your global exception handler has done its work, you'll want to redirect the users of your website to a friendly page that tells them that something has gone wrong, and then provide them with customer support information as well as a link back to your web application's home page.

C# Object Oriented Programming

So far in C# Essentials we have looked at the basics of programming in C# such as variable types and flow control. Although it would be possible to write a functional program using these techniques, there is much more to becoming a proficient C# programmer. C# is, above all, an object oriented programming language and as such any C# programmer will be expected to create object-oriented applications using this language.

Object Oriented Programming

Four core concept of OOP Object Oriented Programming. 1.Inheritance, 2.Polymorphism, 3.Abstraction and 4.Encapsulation

Object-Oriented Programming Concepts

This is the first in a series of articles describing the use of object-oriented programming techniques as implemented by the C# programming language. This series follows the C# Fundamentals tutorial that beginners are advised to read first.

Overview of SharePoint Object Model

SharePoint offers a set of structured server-side objects those are widely used to program SharePoint Applications. These objects are hierarchically arranged and you can drill down through the object hierarchy to obtain the object that contains the components of SharePoint Application you need to use in your code.

What is the difference between "dynamic" and "object" keywords?

Let's take a quick look at the object keyword first. I'm not going to talk a lot about it because it's been around since C# 1.0. This keyword is nothing more than a shortcut for System.Object, which is the root type in the C# class hierarchy. (However, as Eric Lippert pointed out in his blog post, not everything in C# derives from object.) This is a powerful mechanism, since you can assign almost any value to instances of this type.

SQL Connection String

We can learn or know how can we connect the database from our .net. This will help for freshers or .NET beginners!


Defines the attributes of a Transact-SQL server cursor, such as its scrolling behavior and the query used to build the result set on which the cursor operates. DECLARE CURSOR accepts both a syntax based on the ISO standard and a syntax using a set of Transact-SQL extensions.

How to bind GridView and DropDownList controls using DataTable object

In .net framework 2.0, you can load a DataTable in memory by consuming a data source using a DataReader. In this version you will find the flexibility in accessing the DataReader means write access code once and use again and again using DataReader. To see the functionality of DataTable consider an example that is created using VS2005.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend