When I try to insert a record, I get this error : The underlying provider failed on Open. This error occurs only with IIS and not with VWD 2008\'s webserver. In the EventViewer
I was getting the same problem and after doing debugging i saw that i am creating the new instance of DB Entity on every action and making new instance of Db Entity means openning new connection with db.
Below is the code :
Private tmpConnection As New DbModel.DbEntities
so by calling the variable again and again its creating new instance of DbEntites and opening new connection to db.
so i write a small function for this and that solved my problem. Now no more error.
Private tmpConnection As DbModel.DbEntities
Public Function dbCon() As DbModel.DbEntities
If tmpConnection IsNot Nothing Then
If tmpConnection.Connection.State = ConnectionState.Closed Then
Try
tmpConnection.Connection.Open()
Return tmpConnection
Catch ex As Exception
My.Response.Redirect("dberror.aspx")
End Try
Else
Return tmpConnection
End If
Else
tmpConnection = New DbModel.DbEntities
Try
tmpConnection.Connection.Open()
Return tmpConnection
Catch ex As Exception
My.Response.Redirect("dberror.aspx")
End Try
End If
Return Nothing
End Function
and last thing in your connectionstring please add "Connect Timeout=30;"
thats working so perfect for me