Ido, Is there a place where I can check the documentation for the Enterprise Library or do I need to download it and install it first?
Francis, I have a process that receives thousands of Xml messages every day and saves them to the database. I don't want to open a new connection for every file that is processed as this is not a good practice in terms of managing Oracle's internal resources. So the steps are: 1. open a connection; 2. start processing files, one by one; 3. close the connection when there are no more files to process; The thing is that while the files are processed, the connection can be lost. Evidently, the insertion of the data will fail, but the error indicated in the exception raised has different values, depending on what exactly caused the connection to go down. Anyway, my code catches the exception (which is not a constraint violation, so it does not ignore the file) and moves on to the next file. Before every file is processed I check whether the connection is still open. In the case of an error, OracleConnection.State will still be ConnectionState.Open although the connection has gone down. If you remember from the good old MFC days, CDatabase::IsOpen returned false in such cases - sign for us to try and re-open the connection. Of course, I could re-engineer the whole thing and close the connection myself, every time an exception is raised (other the constraint violations), but I hoped there was an easier way to do this, such as a method IsConnectionOpen that would return true or false whether the actual connection is still opened or closed. Cheers, Eddie -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Knebels, Francis Sent: Wednesday, April 13, 2005 10:07 AM To: [email protected] Subject: Re: [ADVANCED-DOTNET] State of a database connection How long are you keeping connections opened? Are you passing open connection around? What about only opening the connection when you need it. Are you worried about conforming to the ACID rules for databases? Then I would suggest using a transaction. using (OracleConnection conn = new OracleConnection(_connString)) { using (OracleCommand cmd = new OracleCommand("select * from cidb.msg_hdr some_table", conn)) { if (conn.State != ConnectionState.Open) { conn.Open(); } using (OracleDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection | CommandBehavior.SingleRow)) { Debug.Assert(conn != null, "connection is null"); Debug.Assert(conn.State == ConnectionState.Open, "connection is closed"); while (rdr.Read()) { //do something with the rdr } //end while read() } //end using reader } //end using } //end using --Fran -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Eduard Lascu Sent: Wednesday, April 13, 2005 9:20 AM To: [email protected] Subject: Re: [ADVANCED-DOTNET] State of a database connection Ido, That property is implemented by the OracleConnection class too (which inherits IDbConnection interface). The problem is that the property is not internally updated. It will change from ConnectionState.Open to ConnectionState.Close and the other way around only when the user calls Open and Close on the connection object. I need something to tell me that the connection has gone down when I try to use it. If the connection was opened, the State will stay ConnectionState.Open until I call Close on the connection object. Meantime, the physical connection can be interrupted by some external conditions, and there is no way I can tell that. I hope I was clearer this time. Thanks, Eddie -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of עידו שמואלסון Sent: Wednesday, April 13, 2005 5:15 AM To: [email protected] Subject: Re: [ADVANCED-DOTNET] State of a database connection In System.Data.IDbConnection check the State property. This return the System.Data.ConnectionState enum. Best Regards, Ido Samuelson Senior Consultant Magen - Microsoft Technology Center -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Eduard Lascu Sent: Tuesday, April 12, 2005 9:58 PM To: [email protected] Subject: [ADVANCED-DOTNET] State of a database connection I recently ran into a problem trying to figure out what is the state of my Oracle database connection object (I refer to Oracle specific classes, but I assume it's the same throughout the entire Framework Class Library). When I get the OracleConnection.State property I obtain ConnectionState.Open even when the connection has actually gone down recently. Executing a command will raise an exception, but I need to check the state of the connection before I go to execute the command. I guess something like the old CDatabase::IsOpen would be great. Did anyone here have implemented an IsDatabaseOpen method that will check the state of the connection? I could issue a dummy SQL statement, such as "select sysdate from dual" or something inside the IsDatabaseOpen method, but I noticed that the error raised can have a different code whether you disable the local network, unplug the cable or just reboot the database server. I checked all the methods offered in the interface and there is little to use to create this functionality. Any idea would be great. TIA =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com ---------------------------------------------------------------------------- -- Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. ---------------------------------------------------------------------------- -- =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
