+ Reply to Thread
Results 1 to 2 of 2

Thread: SQL-SERVER Query

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    10

    SQL-SERVER Query

    I want to achieve that query :
    Code:
    SELECT        userID, username , password
    FROM           Users
    WHERE        (username = textbox1.text) AND (password = textbox2.text)
    How can i achieve that in C# ?

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    41
    here is the proper code in C# :
    Code:
    using (var con = new SqlConnection("connection string"))
    {
        con.Open();
        var cmd = new SqlCommand(@"SELECT userID, username, password FROM Users WHERE (username = @username) AND (password = @password)");
        cmd.Parameters.AddWithValue("@username", textboxUsername.Text);
        cmd.Parameters.AddWithValue("@password", textboxPassword.Text);
    
       cmd.ExecuteNonQuery();
       con.close();
    }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

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