Re: check username and password in database
- From: "Kevin O'Brien" <kobrien@xxxxxxxx>
- Date: Mon, 2 Oct 2006 09:32:49 -0400
Hey,
I have the errors worked out except for:
Command.Connection = MyConnectionObject
I get the error:
'MyConnectionObject' is not declared.
I tried putting in the name of the data set in place of Myconnectionobject
but that didn't work either. any help would be greatly appreciated!
Thanks,
Kevin
"Spam Catcher" <spamhoneypot@xxxxxxxxxx> wrote in message
news:Xns984AAA0C02FA8usenethoneypotrogers@xxxxxxxxxxxx
"Kevin O'Brien" <kobrien@xxxxxxxx> wrote in
news:Oli5KJa4GHA.3604@xxxxxxxxxxxxxxxxxxxx:
So you are saying I should created 2 unbound textboxes to prompt for
username and password and name the textboxes UserName and Password?
Then I can run this SQL select statement right from my VB code?
Exactly ; )
To query the DB, you can do:
Dim Command As New SqlClient.SqlCommand
Command.Connection = MyConnectionObject
Command.CommandText = "SELECT COUNT(1) FROM TABLE WHERE UserName =
@UserName AND Password = @Password"
Command.Parameters.Add(New SqlClient.SqlParameter("@UserName",
txtUserName.text))
Command.Parameters.Add(New SqlClient.SqlParameter("@UserName",
txtPassword.text))
'If count > 0 means username + password matched
If Command.ExecuteScalar > 0 Then
MsgBox("Successful Login")
Else
MsgBox("Try Again")
End If
.
- Follow-Ups:
- Re: check username and password in database
- From: Spam Catcher
- Re: check username and password in database
- Prev by Date: Windows Media Encoder SDK (push server error)
- Next by Date: Re: Handle Worked - can someone please double check
- Previous by thread: Windows Media Encoder SDK (push server error)
- Next by thread: Re: check username and password in database
- Index(es):