Guys please help me out here,i have a windows login form that needs to connect to my sql server 2005 database and check wether the username and password is correct or can i do that please help me out here...

I would suggedst that on the click event of the button to login, you need:

  • Create a SQLConnection to the SQL Server pointing to the right database, and open it.
  • Create a SQLCommand that will return a record if the user and password exists in the relevant table of the SQL database usiing a CommandText like

    SELECT * FROM yourtable WHERE UserName = '" & textBoxUserName.Text & "' AND Passwrod = '" & textBoxPasswrod.Text & "';"

    and using the opened connection on the step before (Obviously you'll need to replace the table name of yourtable with a valid one, and also the field names and the textbox names).

  • Then create an SQLDataReader using the command created on the previous step and try to Read it.
  • If the Read fails, then the entered values are not a valid user/password pair.
  • Do not forget to close the reader and the connection.

Som hints.

  • When defining the password textbox, set the password character in the textbox properties.
  • Is usual to encrypt the password and store it encrypted. In this case, you will need to use the same encryption method used to create the passwrod.
  • Is a bad design to store the passwords in clear text.

Hope this helps

I suggest you do a little googling first, if you type in your article title in the search bar a million pages will come up.
But before you start here is a check list
1) Do you have SQL Server installed?
2) Visual studio working properly?
3) Do you have a database with a table of users?

This article has been dead for over six months. Start a new discussion instead.