I've built a small PC app that resides in the Task Bar Tray until one of our employees sends a signal to it with a handheld device.

When the PC app is activated, we connect to the SQL Server to retrieve records using Integrated Security on the PC:

Private m_conn As SqlConnection

Public Sub New()
  m_conn = New SqlConnection("Data Source=ACTIVE1;Initial Catalog=Inventory;Integrated Security=SSPI;")
  ' more code that isn't relivant
End Sub

The problem is that after the PC app has sat around idle for a few hours, the employees get the generic SQL error message "Cannot generate SSPI context." Basically, it can not log in.

My routine that uses the SQL Server is all contained, so I don't know how to prevent this error.

Private Sub ViewData()
  Dim cmd As New SqlCommand("SELECT * FROM PartsTable WHERE SN=@SERNO", m_conn)
  cmd.Parameters.AddWithValue("@SERNO", SN)
  Dim da As New SqlDataAdapter(cmd)
  Dim dt As New DataTable()
    If (0 < dt.Rows.Count)) Then
      ' sometimes it gets here, but not if the app has been idle for a while
    End If
  Catch ex As Exception
  End Try
End Sub

If I can connect 5-10 times straight, what would cause code like this to fail after it has been sitting idle for a while? When the PC app is activated, a Dialog Box is displayed that the Employee has to confirm the operation on. Only then is this routine called.

10 Years
Discussion Span
Last Post by Jx_Man

Problem resolved. It turned out that our System Administrator doesn't know what he is doing. He set up the account incorrectly, and made changes to the account profile while it was in use.

The code above works fine.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.