How do I code a login to my VB.net program

  • Thread starter Thread starter B&W
  • Start date Start date
Dr_Evil said:
Trust me - you don't need to code your own login screens, nor do you need to design your user security tables in your database. This has all been provided for already by the .Net framework.

1. There's a script that will generate all your database tables. It holds an extensive set of info for user and membership security data.

2. .Net has it's own login components. In VS2005 you can drag the Login control onto your page, which provides for entering user credentials and logging the user in. Also you can enable the "Forgotten password" mechanism.

You need to watch the video i posted earlier and have a good read on that site i posted earlier. They will help you understand how to use this stuff.


worth looking into but as nOOb said it depends if he wants a quick and dirty solution or not.

Ive had a quick look at the membership provider and there is a lot of information to digest where as the method i posted will work and uses his existing skill set.

Which is best to use all depends on how much time the op has and in what context the program is to be used.

If i was starting a new project then i would probably have a good look at the membership provider as most of the addtions to .net are increadbly useful once you know how to use them.
 
Shadez said:
Like i said it might be worth looking at DrE's solution, im an old vb6 developer who has resently moved to .net and dont know everything about it.




well this is a kick your self error..... look at the quotes at the end of the string.

:o . can login now with user and pwd from the db. however its kinda pointless since you can supply an incorrect user/pwd and still access the rest of the program.
 
hehe check your if statement.

If dr.Read = False Then
MessageBox.Show("Authentication Failed...")
Else
MessageBox.Show("Login Successful...")

End If

frmMenu.show - I'm guessing that's in the wrong place. You have it at the end. Try this: -

If dr.Read = False Then
MessageBox.Show("Authentication Failed...")

Else
MessageBox.Show("Login Successful...")
frmMenu.show

End If
 
Last edited:
yeh. silly me. still needs to be fine tuned but more or less works. thx for the help guys.
 
The login controls to use with .net membership providers are ASP.net only, I certainly have never seen them for winforms and can't see them after having a brief look just now. Have any of the people recommending this actually used them in winforms?
 
The only downside with the controls that come with VS2005 (if we are talking about the same thing here) is that you have to use a separate SQL Server 2005 Express db to hold the user data in. As a test I tried using a full 2005 install but it won't play ball - something in the connection string it doesn't like/isn't supported ("User Instance=True" IIRC).. something I wasn't too happy about, I was going to do a quick'n'dirty move of an internal site from classic asp to .NET 2 if this had worked without having to have a second database :(
 
riddlermarc said:
The only downside with the controls that come with VS2005 (if we are talking about the same thing here) is that you have to use a separate SQL Server 2005 Express db to hold the user data in. As a test I tried using a full 2005 install but it won't play ball - something in the connection string it doesn't like/isn't supported ("User Instance=True" IIRC).. something I wasn't too happy about, I was going to do a quick'n'dirty move of an internal site from classic asp to .NET 2 if this had worked without having to have a second database :(

No u don't - u can use an already existing SQL DB!
 
Dr_Evil said:
No u don't - u can use an already existing SQL DB!
Really, that's not what I found :/ I had the connection working, the db was set up by running the Web Site Administration Tool but the login details pages themselves wouldn't connection to the SQL Server instance.. I put it down to the fact I was using forms authentication and for that you needed "User Instance=true" in the connection string, something that is only supported by 2005 Express. When you ran the pages, you couldn't log in..

One of our dba guys here looked into it too, he was stumped but maybe we were missing something obvious - got a link to further info?
 
riddlermarc said:
Really, that's not what I found :/ I had the connection working, the db was set up by running the Web Site Administration Tool but the login details pages themselves wouldn't connection to the SQL Server instance.. I put it down to the fact I was using forms authentication and for that you needed "User Instance=true" in the connection string, something that is only supported by 2005 Express. When you ran the pages, you couldn't log in..

One of our dba guys here looked into it too, he was stumped but maybe we were missing something obvious - got a link to further info?

did you run the script to generate the required tables in your existing database? Did you create the user login to the db and grant ownership on the security tables for that user? Did you code and test the login string properly?
 
Dr_Evil said:
did you run the script to generate the required tables in your existing database? Did you create the user login to the db and grant ownership on the security tables for that user? Did you code and test the login string properly?
Aye, the required tables were generated in SQL 2005 and the connectoin string works okay 'cause you could add/tweak users via the Admin Tools page. It was ONLY when you submit the user login from the web pages it would refuse to acknowledge it :/
 
Back
Top Bottom