|
-
Jun 28th, 2010, 12:08 AM
#9
Re: Validate Credentials Against User Record in Database
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:
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:
Dim connection As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Ernest\Desktop\dbCredentials.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True") Dim command As New SqlCommand("SELECT COUNT(*) FROM User WHERE UserID = @UserID AND Password = @Password", _ connection) With command.Parameters .AddWithValue("@UserID", Me.txtUserName.Text) .AddWithValue("@Password", Me.txtPasssword.Text) End With connection.Open() If CInt(command.ExecuteScalar()) = 0 Then Else Me.DialogResult = Windows.Forms.DialogResult.OK End If connection.Close()
I've made sure to name my table, User and the columns, UserID and Password.
Any ideas?
Thanks
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|