none
login error in Windows App using SqlClient.SqlCommand RRS feed

  • Question

  • I get a strange error:

    Login failed for user 'PP_Reporting'.
    Cannot open user default database. Login failed.

    It is strange because it is from the same code I use throughout my application and it is working in ALL other cases.

    Also because it comes up with a user name "PP_Reporting" that I do not use and it doesn't exist in the db nor in the application.

    Here is the code that runs:

    Private Sub btnCalculate_Click(sender As System.Object, e As System.EventArgs) Handles btnCalculate.Click
            Dim SQL As String
            Dim result As Integer

            conn = New SqlClient.SqlConnection(My.Settings.PP_Conn_Prod)
            'Open connection
            conn.Open()

            'Update initial Wires values
            SQL = "EXEC dbo.usp_WiresCalculate_specificmonth '" & MonthTmp & "'"

            cmd = New SqlClient.SqlCommand(SQL, conn)
            result = cmd.ExecuteNonQuery()

            cmd.Dispose()
            conn.Close()

            'Refresh Grid
            Me.WiresTableAdapter.FillBy_Month(Me.ProductProfitabilityDataSet.Wires, MonthTmp)
    End Sub

     

    Again, I use this same code in various other sections/forms only changing the stored procedure that it is executing.

    The Connection setting in my Settings uses Integrated Security

    Data Source=DBGN03-OPS;Initial Catalog=ProductProfitability;Integrated Security=True

     

    Additionally I removed the code and re-copied the code from another section (that is working) and just changed the stored procedure.

    Still fails with the same error.

    Not sure where else to troubleshoot this problem.


    Gary M
    Tuesday, November 8, 2011 6:55 PM

Answers

  • Just found the answer.  It was SQL Server issue.  The stored procedure was calling an internal query pointing to a linked server which used that acct:  PP_Reporting.

    The server had changed and therefore did not exist any longer.  A new linked server needed to be set up.

     


    Gary M
    • Marked as answer by GaryMac12 Wednesday, November 9, 2011 4:19 PM
    Wednesday, November 9, 2011 4:18 PM

All replies

  • What type of application is this? Desktop? Web app?

    Since you're using trusted security the application process appears to be running under an account called PP_Reporting.


    Paul ~~~~ Microsoft MVP (Visual Basic)
    Wednesday, November 9, 2011 4:08 PM
  • Just found the answer.  It was SQL Server issue.  The stored procedure was calling an internal query pointing to a linked server which used that acct:  PP_Reporting.

    The server had changed and therefore did not exist any longer.  A new linked server needed to be set up.

     


    Gary M
    • Marked as answer by GaryMac12 Wednesday, November 9, 2011 4:19 PM
    Wednesday, November 9, 2011 4:18 PM