I'm working on a side project/consulting job for my former employer...basically I want to recreate an app I did in VB6 using VB2005. It's a simple app, but it was built when I was less experienced, and while I've got the business logic, I'm having troubles getting to a point where I can actually start working with the business logic :-/. Anyway.....can anyone point me to a tutorial or something or give some pointers on where to start to do the following?

I want the app to start, prompt for a username and password, then try and connect to a SQL Server db using that username and password. If it successfully connects, I want to then display the main form, otherwise I want to quit the app (probably with some feedback or something).

What I have envisioned, which I've started but am stuck, is loading the Main form first, and from that, calling a Login form. The Login form then tries to connect to the db, and if successful, returns back to the Main form, with the db connection info. If it won't connect, then the Login form closes and the Main form closes.

Right now I'm just trying to get one form to call the other and open and close based on the logic above (but without the db check) and am stuck.

Additionally, I'd like to eventually have the DB servername and database name in a app.config file, but I haven't even got that far as to figure out how to do that. I'm pretty comfortable with ASP.NET and C#, but I haven't worked with VB at all in awhile, let alone a windows forms app. Any help, please? Thanks!

Recommended Answers

All 2 Replies

They are pretty similar. Rule 1 of logins though.. never present anything to a user until authenticated so dont call your main form and then the login form.
In your app startup you could load (but not show) the main form. I prefer to use the MVC pattern and so i instantiate a controller... the constructor of the controller initializes the login and db connection. If login is successful then the controller will create the main form and away we go. If login is not successful then show a message box (or give them a couple of goes at it) and then close it all down. As you havent hit Application.Run yet the app will shutdown smoothly.

Thank you for the reply! It's starting to come back to me, and that's pretty much how I set things up - the login form starts, tries to connect, and if successful it loads the main form, otherwise it gives an error message. WOohoo! I just got a couple of books from Amazon today, and am excited about digging into those soon, too. Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.