Here are some simple steps to create login functionality in your WinForms app.
1. Create a new WinForms project.
2. Add a new form to act as the Login dialogue. You can use the item template supplied with VS or create your own.
3. Open the ApplicationEvents code file from the button on the Application tab of the project properties.
4. Create a Startup event handler using the drop-down lists at the top of the code file and add the following code:
5. Add the logic to your Login form to validate the credentials supplied by the user. You may like to use this as a basis.
6. If the login succeeds set your Login dialogue's DialogResult property to OK. If the user presses the Cancel button or fails to login within a prescribed maximum number of attempts then set the DialogResult to something else.
If the user logs in successfully the app will start normally, otherwise it will exit without ever creating a main form.
Last edited by jmcilhinney; Dec 14th, 2008 at 10:35 PM.
I have attached a VS 2008 project that demonstrates logging into a WinForms app by validating against a database. An Access database (MDB format) with three existing users is included in the project.
Note that the login form contains code to validate using a Data Source and code to do it all manually. There is a Boolean constant that can be toggled to change which gets used. I added a scalar query to the TableAdapter in the designer to provide the validation functionality.
I have attached a VS 2008 project that demonstrates logging into a WinForms app by validating against a database. An Access database (MDB format) with three existing users is included in the project.
Note that the login form contains code to validate using a Data Source and code to do it all manually. There is a Boolean constant that can be toggled to change which gets used. I added a scalar query to the TableAdapter in the designer to provide the validation functionality.
Any chance you could convert this to vb I tried using an online converter but it keeps giving me an error
Doh idiot, I am stuck trying to get it to connect to a remote SQL server I have added the remote connection strings to my app config and kept the other referances the same for now (same DB tables) if I run the app with tableadaptor I get "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done." error on this line
if I try to run it as a data adaptor I get this error "An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'."
Doh idiot, I am stuck trying to get it to connect to a remote SQL server I have added the remote connection strings to my app config and kept the other referances the same for now (same DB tables) if I run the app with tableadaptor I get "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done." error on this line
if I try to run it as a data adaptor I get this error "An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'."
and ideas
thanks
M
I have sorted out my remote conection can anyone point me in the right direction in order to md5 hash my password field or is it possible to have a secure tunnel (connection to the SQL server?)