How to create a single Oracle Database connection method or function to be used on or by all classes and pages that want to connect to the database?

 How to create a single Oracle Database connection method or function  to be used on or by all classes and pages that want to connect to the database? How can I create one method or function in csharp to be used on all pages or classes when conenction to the database? Please give an example.

I have database connections which I am using on each and very page or classes, but I can I put in one page then I just start  calling it?

Database connection I am using:

 

  OracleConnection dbconnection;

    this.dbconnection = new System.Data.OracleClient.OracleConnection();
  this.dbconnection.ConnectionString = "user id=studentuser;data source=vdsoure;password=888hfg1";

0
Mobzam
4/20/2009 6:30:13 AM
asp.net.oracle 2269 articles. 0 followers. Follow

2 Replies
1539 Views

Similar Articles

[PageSpeed] 23

I used to create an 'OracleConnection' whenever I need, instead of checking deeply for the way you expect to have. I think it's a one-step action!


Many Thanks & Best Regards,
HuaMin Chen

(Mark it as answer if it does help you!)
0
wmec
4/20/2009 8:50:45 AM

Hi,

   To add to what HuaMin said, you dont need to do that in .NET; system.data.oracleclient maintains a connection pool automatically behind the scenes so con.open is a cheap call that just gets a connection from the pool rather than opening a hard connection. Just create a new OracleConnection when you need it, and Dispose of it as soon as you're done with it so it can be returned to the pool.

Hope it helps,
Greg

0
greg
4/20/2009 6:58:39 PM
Reply:

Similar Artilces:

Unable to connect the oracle database using connection cache
Hi I created a connection cache for oracle database with the following parameters in jag manager In Database connection properties tab: ------------------------------------------- Server Name = jdbc:odbc:xyz ( where xyz is the dsn name created in windows ODBC setup) User Name = bgb password = bgb In Driver properties tab: --------------------------- DLL or class name = sun.jdbc.odbc.JdbcOdbcDriver JDBC option is checked In Cache properties tab: --------------------------- Enable cache-by-name access is checked I am able to ping the connection cache successfully in con...

Can't connect to Oracle database using Oracle 10g Client in Windows 2003 Enterprise
Hi, Our test environment is Windows 2003 enterprise with IIS and Oracle 10g client installed. I wrote a simple asp.net program to connect to a Oracle database and display the select result in a datagrid. But can't connect to Oracle. It seems .NET can't find the oracle client. Any idea is highly appreciated. Thanks in advance. Joey...

how to connect Oracle Database in Smart Device Application using .Net Compact Framework
Edited by moderator XIII: Please read this article: How to post on forums Dear all, I am using Smart Device Application using .Net Compact Framework & want to access Oracle database (such as inserting,updating,retrieving data from oracle database). Can anyone provide me any code (in C#) for data access or any link related to this topic? Regsrds Anirban You did not mention where your oracle database resides. One way is to write a web service where you can write all your code related to database access and manipulation. You can call this web service from your sm...

Creating Oracle Database Connection
I am getting a create catalog error when I try to create an Oracle connection in Powerbuilder version 10.5. I have create table permissions with the ID that I'm using. What could be causing this error? By default PB will use the SYSTEM userid to create the catalog tables. On the db-profile system tab you can specify the owner of the PBCATxxx tables. -- Terry Dykstra (TeamSybase) http://powerbuilder.codeXchange.sybase.com/ http://www.pb9books.com product enhancement requests: http://my.isug.com/cgi-bin/1/c/submit_enhancement <Stephen Jung> wrote in message news:4...

Oracle database connection using Visual Studio 2005 and .Net 2.0 framework
My connection string is in my web config file, generated when I added a sql data source.  I can go under tools and connect to database and compare the connection string there to the one in web config and they are the same but when I try to view my page which contains a gridview I get a database connection error saying  "Keyword not supported: 'unicode'."  When I remove the unicode=true parameter from the connection string then I get an error message about trying to connect to sql server.  Could someone please give me a clue on how to go about solvin...

How to create a connection to a sql Database from a database class?
Hello Mate!,                 I have a Database clss and a web form I have just mentioned in the Web config file of the webform for connection string as <configuration> <appSettings/> <connectionStrings>  <add name ="SQL" connectionString="Server=Servername;Database=mydatabase;uid=some user id ;pwd=some password;"/> </connectionStrings ></configuration> and i have just mentioned in a class in which i want to create a connecti...

How can I change my connection to a different database...it is not connecting to the database I created.
My data is connected to the ASPNETDB.MDF database. Is this a must that I have it connected to this database or can I have it connected to a database that I created. You can connect to different database such as sql or other access files. All you have to do is to define which connection string to use within your web.config file. If you want to make sure that your database is prepared to be used, use features such as ASPNET_REGSQL.EXE at VS Command Prompt. Hope this helps. Jae.jae.lee@jaeleeandco.com I'm in the Army...here in Georgia. Is it cold there.. Hi Jae,    &nb...

Oracle 8i client connected to Oracle 9 database.
I have connected my Powerbuilder 9 application to a Oracle 9i database using Oracle 8i client. My Oracle home is set to 8. My Powerbuilder DB connection is using Oracle 8. Things seem to work. Why? In general, there will be compatibilty between client and server versions here; however, you'd have to check Oracle for their specific supported configurations. If you try to access anything new in Oracle 9 (like new datatypes, etc.), I expect you'll see problems that may be handled gracefully or not so gracefully. On 3 Dec 2004 13:03:31 -0800, Kurt Pager wrote: >I have co...

How to create a connection between oracle database and the webform
 hi, is anyone here possible to teach me how to connect Oracle  database to my webform? To connect to an Oracle database using OraOLEDB, the OLE DB connection string must be as follows: "Provider=OraOLEDB.Oracle;Data Source=R2D2;User ID=foo; Password=bar"; Make sure that you have entry for the data source in tnsnames.ora file and TNSListener service is running. For more information on OraOLEDB provider refer to Orcale9i documentation. And as an example code try this private bool ValidateUser(string strLogin, string strPwd){bool bRet = false;OleDbConnection c...

Cannot connect to oracle database when using WAP
Does anyone know of any problems connecting to (oracle) databases when using WAP ??? I have a problem when trying to access my oracle database when using WAP, im not sure if the problem is related to oracle but it is definitely related to WAP and definitely not related to the ASP.NET Development Server. The code below works in a standard web project, its a very simple project with a 'Default.aspx' page that loads and connects to a database using OLE and / or an OracleClient, it works fine as you would expect. Exactly the same code but in a WAP project throws an error when trying to open t...

Oracle Database - .NET
first of all hello and nice to see you all. this is my first post on this forum and it seems pretty useful..okay just got a small question... i have started to implement Compiere (http://www.compiere.org) in a factory 1. Installed Linux 2. Installed Oracle XE 10g what i want to do is to connect on the oracle database from VS .NET 2005 i checked ConnectionStrings.com nothing worked .. anyone got a solution for this?Did any one every connect from ASP .NET or a Windows Application on oracle running on a linux (CENTOS server)?  thankskimoo   Hi,    ...

Connect Oracle database using TNS
Dear all  I connect Oracle database in following method .(DSN method ). conn.ConnectionString = "Data Source =slt;User id =Giri; password =soft123;" I want to know how to connect Oralce database using TNS .    Regards Giridaran It'll be the sams as DNS except that you'll have your connection details in TNS as something similar to below: SLT=  (DESCRIPTION =    (ADDRESS_LIST =      (ADDRESS = (PROTOCOL = TCP)(HOST = <hostip>)(PORT = 1521))    )    (CONNECT_DATA =    ...

VB.NET to oracle database connection
Hello,  I've been trying for days to try to connect to oracle database but still no success, I've put the connection in the web.config in the <ConnectionString> place, created the connection on the page itself: Private sqlCon As New OleDbConnection("Provider=msdaora;Data Source=Server1/orcl2;User Id=Train;Password=Train;") but still no success, Now I'm trying to make a local connection throught Tools > Connect to database but still no success. All I get is this: System.Data.OleDb.OleDbException: ORA-12154: TNS:could not resolve service name at Could ...

Database Connection???How to connect a Database in an other server?
How to connect a Database(.mdb) in an other server? Can I use the connection string like below? mycon.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=http://www.****.com/***/mydb.mdb" You can not. That simple. Access is file based. No a client/server architecture.Thomas TomiczekPowerNodes ApS(Microsoft MVP C#/.NET)---Building a Website? Try the PowerNodes CMS - http://www.powernodes.com/ Correction: you can. Just make sure you can reach the acces db file - through a file share that is bound as drive. Not that you should. Performance will be horrib...

Web resources about - How to create a single Oracle Database connection method or function to be used on or by all classes and pages that want to connect to the database? - asp.net.oracle

Connection - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

iMedia Connection: Interactive Marketing News, Features, Podcasts and Video - iMediaConnection.com
If you send more email, you might make more money. Then again, you might destroy your reputation and revenue stream. Here's how to know what ...

HTTP persistent connection - Wikipedia, the free encyclopedia
... tacked on to an existing protocol. If the browser supports keep-alive, it adds an additional header to the request: Following this, the connection ...

MOTHER’S DAY: Facebook Examines Connections Between Moms, Kids
With Mother’s Day on the calendar this coming Sunday, Facebook examined the relationships between mothers and their children on the social network, ...

Kings Cross identities arrested in connection with murder
Two Kings Cross identities&nbsp;have been arrested in connection with the murder of a man at Sydney hotel.

Governor declares state of emergency in connection with California methane leak
... of Emergency Services) On Wednesday evening, California Governor Jerry Brown declared a state of emergency in Los Angeles County in connection ...

Tons Of Methane Are Spewing Out Of California, And There’s A Connection To The Governor
The out of control leak has forced thousands of residents to flee their homes. Gov. Brown's sister is a paid board member at the company that ...

Report: Man arrested in connection with Ashley Olsen's murder
Italian media agency reports that a non-EU male has been arrested in the murder of the 35-year-old American

Toyota and Kymeta rely on satellites to power this Mirai's data connection
They're hoping to achieve gigabit wireless speeds within the next few years.

Test Claims To Show T-Mobile’s YouTube “Optimization” Is Just Connection Throttling
... on the same network, and at the same time of day. They tested video streaming against three other kinds of downloads and measured the connection ...

Resources last updated: 1/15/2016 7:39:08 PM