Hey JMC,

When I use your code as is, I receive the following error:

Invalid object name 'User'.
On the following line:

VB.NET Code:
  1. If CInt(command.ExecuteScalar()) = 0 Then

When I look into the error, from the debugger help section, there are two generic tips:

Verify that you are connecting with valid credentials.
Make sure that the credentials you are supplying are valid. For more information, see How to: Access SQL Server Using Predetermined Credentials.

Verify that the server name is correct and that the server is running.
Make sure that you are using the correct server name, and that the server can be reached. For more information, see How to: Create Connections to SQL Server Databases.
I've made sure that the credentials are 100% correct and the connection string was copy and pasted from the SQL database wizard.

For references purposes, the following is the code I'm using:

VB.NET Code:
  1. Dim connection As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Ernest\Desktop\dbCredentials.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
  2.  
  3.         Dim command As New SqlCommand("SELECT COUNT(*) FROM User WHERE UserID = @UserID AND Password = @Password", _
  4.                               connection)
  5.  
  6.         With command.Parameters
  7.             .AddWithValue("@UserID", Me.txtUserName.Text)
  8.             .AddWithValue("@Password", Me.txtPasssword.Text)
  9.         End With
  10.  
  11.         connection.Open()
  12.  
  13.         If CInt(command.ExecuteScalar()) = 0 Then
  14.            
  15.         Else
  16.             Me.DialogResult = Windows.Forms.DialogResult.OK
  17.         End If
  18.  
  19.         connection.Close()

I've made sure to name my table, User and the columns, UserID and Password.

Any ideas?

Thanks