Re: [2005] - SQL Login Form
output the error message in the catch block. It will help you debug your program better
Re: [2005] - SQL Login Form
omg... How did I miss that. Will put that in and see what error message is returned...:blush:
Re: [2005] - SQL Login Form
As talkro says. You should always put this code in your Catch blocks:
vb.net Code:
Debug.WriteLine(ex.ToString())
That will write the error message and stack trace to the Output window when you're debugging but it will not affect the performance of a Release version.
That said, it's not a bad idea to have a standard mechanism to log unexpected exceptions in deployed apps so you can easily diagnose issues in applications installed on client systems.
Re: [2005] - SQL Login Form
Thanks for the hint. The error message returned column name "Password" missing which has now been fixed and the code is now working as expected. On a side note, it it possible to close the login form once the main form has been called.
I have called "LoginForm.Close" within the MainForm_Load Sub but that closes all the forms. I them tried "LoginForm.Hide", but when closing the application by the close button during debugging, the program is still running.
Re: [2005] - SQL Login Form
using the form.hide trick, you have to make sure that in the the form closing event of the main form, you close the login form has well.
Re: [2005] - SQL Login Form
A tip of advice, you might want to look up Paramaterization for your sql statement, if you value security.
Re: [2005] - SQL Login Form
If you are connecting to an SQL Server then you should really be taking advantage of Stored Procedures. They offer maximum security because none of your login validation code is exposed, even to a decompile. Then it is simply a matter of sending the login parameters and receiving either a success or a fail response.
Also for security as well as optimization reasons, the login authentication should be called before the main application is even run. In C#, this involves modifying the code in Program.cs. I'm not sure where to insert it in VB.
Re: [2005] - SQL Login Form
Follow the WinForms Login link in my signature.