|
-
Nov 3rd, 2009, 09:58 PM
#1
Thread Starter
Member
character..
hey guys i have just one thing left to finish in my code and i can't seem to find the keyboard shortcut..
Command.CommandText = "SELECT * FROM [members] WHERE Username= '" HEREUsernameTextBox.textHERE "' AND Password='" HERE PasswordTextBox.text HERE"'; "
its like a revers quote?
-
Nov 3rd, 2009, 10:19 PM
#2
Addicted Member
Re: character..
What exactly is your question?
-
Nov 3rd, 2009, 10:38 PM
#3
Re: character..
It's not a reverse single quote (`) or whatever it's called that you need there. To join strings together you use an ampersand (&), which is on the 7 key on a standard QWERTY keyboard. That said, you shouldn't be using string concatenation to insert values into SQL statements. You should be using parameters:
vb.net Code:
Command.CommandText = "SELECT * FROM [members] WHERE Username = @Userame AND [Password] =@Password" Command.Parameters.AddWithValue("@Username", UsernameTextBox.Text) Command.Parameters.AddWithValue("@Password", PasswordTextBox.Text)
-
Nov 4th, 2009, 06:35 AM
#4
Thread Starter
Member
Re: character..
wow.a forum with strait answers..thx
my login form does not seem to work..it doest even show when i build it?
vb.net Code:
Dim Connection As New SqlClient.SqlConnection
Dim Command As New SqlClient.SqlCommand
Dim Adaptor As New SqlClient.SqlDataAdapter
Dim Dataset As New Database1DataSet
Connection.ConnectionString = ("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True")
Command.CommandText = "SELECT * FROM [members] WHERE Username = @Userame AND [Password] =@Password"
Command.Parameters.AddWithValue("@Username", UsernameTextBox.Text)
Command.Parameters.AddWithValue("@Password", PasswordTextBox.Text)
Connection.Open()
Command.Connection = Connection
Adaptor.SelectCommand = Command
Adaptor.Fill(Dataset, "0")
Dim count = Dataset.Tables(0).Rows.Count
If count > 0 Then
Form3.Show()
Me.Hide()
Else : MsgBox("incorect login", MsgBoxStyle.Critical)
UsernameTextBox.Clear()
PasswordTextBox.Clear()
End If
-
Nov 4th, 2009, 07:14 AM
#5
Re: character..
Follow the CodeBank link in my signature and you'll find a thread dedicated to displaying a login dialogue.
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
|