Results 1 to 5 of 5

Thread: character..

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2009
    Posts
    56

    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?

  2. #2
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    Re: character..

    What exactly is your question?

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. Command.CommandText = "SELECT * FROM [members] WHERE Username = @Userame AND [Password] =@Password"
    2. Command.Parameters.AddWithValue("@Username", UsernameTextBox.Text)
    3. Command.Parameters.AddWithValue("@Password", PasswordTextBox.Text)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2009
    Posts
    56

    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:
    1. Dim Connection As New SqlClient.SqlConnection
    2.         Dim Command As New SqlClient.SqlCommand
    3.         Dim Adaptor As New SqlClient.SqlDataAdapter
    4.         Dim Dataset As New Database1DataSet
    5.  
    6.         Connection.ConnectionString = ("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True")
    7.         Command.CommandText = "SELECT * FROM [members] WHERE Username = @Userame AND [Password] =@Password"
    8.         Command.Parameters.AddWithValue("@Username", UsernameTextBox.Text)
    9.         Command.Parameters.AddWithValue("@Password", PasswordTextBox.Text)
    10.         Connection.Open()
    11.  
    12.         Command.Connection = Connection
    13.         Adaptor.SelectCommand = Command
    14.         Adaptor.Fill(Dataset, "0")
    15.  
    16.         Dim count = Dataset.Tables(0).Rows.Count
    17.         If count > 0 Then
    18.             Form3.Show()
    19.             Me.Hide()
    20.         Else : MsgBox("incorect login", MsgBoxStyle.Critical)
    21.             UsernameTextBox.Clear()
    22.             PasswordTextBox.Clear()
    23.  
    24.  
    25.         End If

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: character..

    Follow the CodeBank link in my signature and you'll find a thread dedicated to displaying a login dialogue.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width