The underlying provider failed on Open RRS feed

  • Question

  • I am using a Windows form application with ADO.net entity model 3.5..

    I get the Error message, "The underlying provider failed on Open" with the underlying message "An attempt to attach an auto-named database for file C:\Users\Khurram\documents\visual studio 2010\Projects\EmpManager\EmpManager\bin\Debug\main.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."

    I'm just getting started with ADO.net, so this may be a very Noob'y question. This is the part of the code that the error is at.

          Using MyData As New XCo
              Dim Emps = From x In MyData.Employees Select x
              Dim AvailableEmps As New List(Of Employee)
              For Each Emp As Employee In Emps    'Error Here
                If Emp.Name.Contains(TextBox_SEARCH_EmployeeName.Text) = True Then
                End If
              If AvailableEmps.Count = 1 Then
              ElseIf AvailableEmps.Count > 1 Then
                Dim ssd As New SearchSelectDialog
                ssd.FoundEmployees = AvailableEmps
              ElseIf AvailableEmps.Count < 1 Then
                MessageBox.Show("No match found", "information", MessageBoxButtons.OK, MessageBoxIcon.Information)
              End If
            End Using

    Hope someone could help me, Thanks..

    Monday, August 8, 2011 5:20 PM


  • Hello,

    From your error information, we have some questions need to clarified with you.

    1. Did you ensure if other connection was closed before you opened a new connectiong string or not?

    Normally, database can only be attached to a single instance at a time. Regarding your provide error information, I suggest you check the previous question first. Plus, I suggest you can change your connection string and try it again.


    Larcolais Gong[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Larcolais Gong Wednesday, August 17, 2011 5:48 AM
    Thursday, August 11, 2011 6:39 AM