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

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

If open Database Connection fail how to try again Reopen?

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :ASP.Net


I am using this few lines of codes but when connection fail it never succes open again any idea? 


Dim sConnectionString As String = ConfigurationManager.ConnectionStrings("DatabaseConnectionString").ConnectionString
        Dim objConn As New SqlConnection(sConnectionString)
        For f = 1 To 1
                objConnOpenError = False
                objConnOpenError = True
            End Try
            If objConnOpenError = True Then
                System.Diagnostics.Debug.WriteLine("Error objConn85 " & Now)
                f = 0

View Complete Post

More Related Resource Links

claims authenticated (FBA) user cannot open a connection to our custom application database

We have designed a custom sharepoint site. This site uses a membership provider that I implemented, and the users are stored in our custom application database. These are the steps I follow to reproduce the error: 1. Browse to our site. Select Forms Authentication from the default.aspx selection. 2. Enter in a username from our DB table. This user I have configured as a site collection administrator. 3. Login to the site. The user is authenticated by our membership provider and allowed access (ValidateUser returns true) 4. Browse to a page that attempts to connect to the custom app DB. 5. I get the following error when the page attempts to open a connection to our DB: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server NOTES: The code that opens the DB connection is running with SPSecurity.RunWithElevatedPrivileges. Our application pool account has access to the database. My user can connect to the database fine as well as the user that our  application pool is running as. I have validated the connection string that is being used in the debugger, and that is correct.

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")

Unable to make connection to database?


Hy guys. I try to connect my database for so long so i wrote two type of codes. Let's discuse first on.

I have database called PhoneDirectory.

It have only one table named Residents.

I have button wiht ID="Button1".

I want when i click this button to see all of my residents. 

I want to see the result in DetailsView and to be able to edin, delete and add new resident.

First try with SqlDataSource so i wrote this:

<asp:SqlDataSource ID="Resident Details" runat="server" ProviderName="System.Data.SqlClient" ConnectionStrings="<%$ ConnectionStrings:ThisIsTheConnection%>" 
              SelectCommand = "SELECT * FROM Resident "

Need Oracle Data Provider .CS File for Oracle 10g Database connection !



I need a 'Wrapper.cs' file which takes care of the Database connection ( Oracle 10g) where

i can just call the method with my SQL Query


Gridview1.DataSource = SampleWrapper.ExecuteDatatable("THE SQL QUERY");


Plz Post the link if there is any open source !    

Protect It: Safeguard Database Connection Strings and Other Sensitive Settings in Your Code


Protecting application secrets, such as database connection strings and passwords, requires careful consideration of a number of pertinent factors such as how sensitive the data is, who could gain access to it, how to balance security, performance, and maintainability, and so forth. This article explains the fundamentals of data protection and compares a variety of techniques that can be used to protect application settings. The author discusses what to avoid, such as hiding keys in source code and the use of Local Security Authority. In addition, he presents some effective solutions such as the Data Protection API.

Alek Davis

MSDN Magazine November 2003

Cannot open database "ReportServer$SQLEXPRESS" requested by the login. The login failed. (App Log Ev

I have SQL'08r2x64 freshly installed on a WS'03r2x64sp2 box and WS is also a DC (sorry).  Previously, there was a SQL'05sp3 installation on this box and it worked splendito.  I used the SQL'05 for some minor devel and to host a Backup Exec 11D db/installation; it all was splendito.   Then, i removed SQL'05&BE11D to prepare for an upgrade of this arrangement.  Next, i installed said SQL'08 to be the foundation for a planned Backup Exec 12.5 install.  To date, I can't get to a clean install of SQL'08 and thus have not progressed to installing BE12.5.  I now have this painfully annoying situation (as i've been beating on it for 2 days) where a series of errors occur during boot: 1st: srmSvc; Event ID 12317; File Server Resource Manager failed to enumerate share paths or DFS paths.  Mappings from local file paths to share and DFS paths may be incomplete or temporarily unavailable.  FSRM will retry the operation at a later time. 2nd & 3rd (occurs twice): MsSQL$buExpressSQL; Event ID 18456; Login failed for user 'BOWMAN\ExecSQL'. Reason: Failed to open the explicitly specified database. [CLIENT: <local machine>] 4th: Report Server Windows; Event ID 107; Report Server Windows Service (SQLEXPRESS) cannot connect to the report server database. I couldn't find anything to sink my teeth into for the 12317 error; i

Use Database.Open for ConnectionString from web.config

This is an FYI - I am not looking for a solution:As mentioned in this tutorial (http://www.asp.net/webmatrix/tutorials/5-working-with-data), I tried using my own connectionstring from web.config. I got this error: "Format of the initialization string does not conform to specification starting at index 0."The tutorial suggests to use: Database.OpenConnectionString("SmallBakeryConnectionString") method Instead you should use Database.Open("ConnectionStringName").Ref: http://cytanium.com/forums/yaf_postsm18_Connection-string-problem.aspxThe API Document is missing Database.Open method and also Database.OpenConnectionString info needs to be modified.

Database server connection limit exceeded..

I have an SSIS package and have been adding additional DFTs to it.  Where there are dependencies between transformations I identify them.  However where things can procceed in parallel I do not constrain them form a control flow standpoint.  After adding another DFT I am now getting package failure due to "Database server connection limit exceeded" (my local source database is SQL Anywhere and it has a max connections of 10 in production it will be full blown Sybase and will probably not be so constrained).  I think I can solve the problem just my making control flow dependencies to reduce the amount of parallel activity but I am wondering if there are other things I should consider doing.  For instance are there other settings I can tweak that tell SSIS to run parallel up to X connections out of a connection pool? (or something like that). Some may comment that this relates to my post of yesterday on package strategy (master-child packages or one big package).  I still have one big package for now but may break it into master-child.  Still I think I can control the amount of parallel activities through control flow even if it remains one package. Any thoughts or comments on this would be appreciated. - Charles PS - just ran my package and this time it succeeded - sometimes I hit the limit of 10 connections sometimes not...

Database connection problem in ASP.NET

Hello,            I m having a database problem that I couldnt identify. The IIS loses connection to database once in 3 weeks.  Once  you restart the IIS everything is normal. Looks like IIS is fine because i can go to static pages. When I go to a page that requires database connection I get this error: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - Either the application has not called WSAStartup, or WSAStartup failed. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)   Is this a connection string problem?. because without changing anything if I restart the webserver all is fine.  Is this a problem with application state?   It cant be at the sql server side as other applications on the machine work fine. There is something going on with IIS not sure what it is.   Any help would be appreiciated.   Thanks, Bharani      

Open SQL Server Connection Troubleshooting

Hello, This is regarding ASP.Net (VB) 2.0 and SQL Server 2008.  My project's (there is only one in my solution) has a "Start Action" set to a "Specific Page" (..\Forms\frmMain.aspx).  Occasionally (though not always) a large number of connections (30+) will be opened prior to the frmMain.PreInit event.  These connections stay open for quite some time.  I am closing all of my connections with extreme prejudice.  In my "finally" clause of my try...catch I have myconnection.close.  Immediately after the "End Try" I have myconnection.dispose (redundant, I know).  I have accounted for all connections.  I placed a breakpoint on frmMain.PreInit and then (sometimes) a large number of connections (used SSMS to run sp_who and sp_who2) will have just opened.  What would open a large number of connections prior to the starting page's preinit event?  I am closing (and then disposing) all of my connections.  I thought that I must be missing a myconnection.close in the "finally" clause, but I have looked repeatedly and cannot find anywhere that a connection is open and then not closed.  Also, I do not believe that I have even opened a connection prior to the frmMain's preinit event.        

how many open connection is recommended to leave - in sql server 2008 Enterprise Edition

hi i have my C# program that work with sql-server 2008 Enterprise Edition i have 40 users that connect to this database. i dont close the connection. how many open connection is recommended to leave ? or is it better to close connection ? thank's in advance

help needed re: "Invalid Database Connection"

I'm a novice at adding programs. I have Windows XP, & have tried downloading a homeschool program, but when I click on the icon on the desktop I get this message in a pop-up box: "Invalid Database Connection X Cannot Establish A Valid Database Connection / Exception message: Login failed for user 'soshome09.' Reason: Server is in single user mode. Only one administrator can connect at this time. / Please contact technical support"   *Note: the user 'soshome09' is the homeschool disk I'm trying to open. I don't even know if I'm posting this request in the right area/forum!!!! ANY/All help will be greatly appreciated! thesingingbyrds@hotmail.com

Error in attaching database file and creating a new connection

I am having problem when i was trying to attach .mdf file while create a new connection of SQL server, create a new connection of SQL database file and open the database in Server Explorer. I am using VS 2010 Ultimate and SQL Express 2008 R2.Can anyone please tell me what is the problem I am facing?Here are the error message.1. Attach .mdf in SQL database file and open the database in Server Explorer2. Create a new SQL server and attach .mdf

how to open ssh / secure shell connection using vb and run commands

Hi I need to open connection for Secure shell and run commands from a remote site i am using Vb.net   i have seen many component that can use but i would like to code by my own if i could please give me your brilliant ideas

Cannot open database " " requested by the login. The login failed.

Hi, I am trying to take the backup of the sitecolletion using stsadm -o command, getting the following error. Cannot open database "dbName " requested by the login. The login failed. Login failed for user  'User'. Any help appriciated. Thanks Srikanth Reddy

"Database schema could not be retrieved for this connection" Error using VWD 2010

After downloading VWD 2010 Express. I drag the SQL Data Source, When trying to establish any type of connection get the error below. I CAN connect using the OLE  (.NetFrame data provider for OLE DB work) but CAN NOT connect using (.NetFrame data provider for SQL server) I have VWD 2008 in another PC and work just fine. I did google and tried several solutions that other had with no luck. I know they were not using VWD 2010 but it was the same error. Again no luck with those solutions. If anyone can share it would be greatly apreciated! Thanks in advance!Jimmy "Database schema could not be retrieved for this connection. Please make sure the connection settings are correct and that the database is online. This server version is not supported. You must have Microsoft SQL Server 2005 or later."    

SQL Database Connection Timeout

How do you modify the default 15 second timeout Connection Timeout on SQL databases in SQL 2005, for all users? I am able to modify the value on an individual basis through the options menu on the SQL Server 2005 login window however when signing on as a different user the changes do not carry to that users profile.
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