Hello Friends,
Sometime, you might have notice that, your hosting server is working fine but your database is not working due to which you
might be getting error on website and you might be loosing visitor and ranking in website..
This post is regarding that only, you can manage this issue by two database.
You can have two database at different server and you can call this in global.asax
first you can make ping to first database everytime and if its working you can call first server database and
if you find any issue or server is not working then you can switch to second server using below code..
Let me know, if you have any query..
Sometime, you might have notice that, your hosting server is working fine but your database is not working due to which you
might be getting error on website and you might be loosing visitor and ranking in website..
This post is regarding that only, you can manage this issue by two database.
You can have two database at different server and you can call this in global.asax
first you can make ping to first database everytime and if its working you can call first server database and
if you find any issue or server is not working then you can switch to second server using below code..
Dim connStatus As String
Dim png As New Ping()
Dim pr As PingReply = png.Send("221.256.357.36")
connStatus = pr.Status.ToString()
'--------------------
If connStatus = "Success" Then
If ConnString = "OldConnection" Then
If ConfigurationManager.ConnectionStrings("oldconnection1").ConnectionString <> "" Then
ConnObj = New SqlConnection(ConfigurationManager.ConnectionStrings("oldconnection1").ConnectionString)
Else
Throw New Exception("Connection String is Empty")
End If
Else
If ConfigurationManager.ConnectionStrings("oldconnection2").ConnectionString <> "" Then
ConnObj = New SqlConnection(ConfigurationManager.ConnectionStrings("oldconnection2").ConnectionString)
Else
Throw New Exception("Connection String is Empty")
End If
End If
Else
If ConnString = "newconnection" Then
If ConfigurationManager.ConnectionStrings("newconnection1").ConnectionString <> "" Then
ConnObj = New SqlConnection(ConfigurationManager.ConnectionStrings("newconnection1").ConnectionString)
Else
Throw New Exception("Connection String is Empty")
End If
Else
If ConfigurationManager.ConnectionStrings("newconnection2").ConnectionString <> "" Then
ConnObj = New SqlConnection(ConfigurationManager.ConnectionStrings("newconnection2").ConnectionString)
Else
Throw New Exception("Connection String is Empty")
End If
End If
End If
Let me know, if you have any query..
Thanks Hope this post will help you, if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer
Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com
No comments :
Post a Comment