Is this possible and if so is there a general approach I should take
Hi,
You can do it in this way.
But I should remind you to keep your connection string and other sensitive code in your program secure. ( please check the SqlConnectionStringBuilder.Encrypt .)
Otherwise, you can use encrypted file to save the user and password information. But it is another story.
Thanks
Hello, Yorick
You can save the information (user name and password in the database) as you mentioned in the first post.
When a user run the application, the scenario is:
to access the database to check the data( username and password ) and then give more action.
1: create a table in database to store user name and password (I recommend encrypting the password in the table)
2: make connection to database
3: take SQL query statement to search in the database using the text in User name textboxs as parameter username.(SELECT Password FROM TableName WHERE Users=@username)
4: compare the password returned and the text in the Password textboxs (you may use dataReader, see: http://msdn2.microsoft.com/en-us/library/haa3afyz.aspx)
In this way, you can complete your login form in the application.
For more information, see http://msdn2.microsoft.com/en-us/library/wzabh8c4(VS.80).aspx
Otherwise, you can use encrypted file or somthing else to store the information, but it is another story.
Thanks
Hey thanks,
I have managed to get this working but I wanted to keep track that this user has logged in and only display information
relevant to the user because at the moment the user logs in and it is forgotten who has logged in.
Hi,
So you could keep the identifying infomation in the memory (instead of "verify once and lose forever") during the whole application life time to keep track of who is the current user. Do verifying where you need.
For example, when a user login then you record his user name in a general variable of application scope. Then detect the user name recorded. Just something like session mechanism in ASP.NET
Thanks