# VBForums CodeBank > CodeBank - Visual Basic .NET >  VB.NET - Login Screen using ADO.NET Class

## Pirate

A login window demo .

----------


## cgj

Thanks Pirate

----------


## Pirate

To try the demo and verify it's working , here is the info : 

UserName : abc
Password :  123

----------


## private1337

a question to addon, can I lock *.mdb file using Microsoft Access or other program so no one can access it unless with a password?

----------


## Pirate

> a question to addon, can I lock *.mdb file using Microsoft Access or other program so no one can access it unless with a password?


You mean password-protect it with code or right from MS Access ??

----------


## private1337

> You mean password-protect it with code or right from MS Access ??


anyone will do, it will be better if MS Access can.

----------


## Pirate

> anyone will do, it will be better if MS Access can.


Open your database in MS Access , go to Tools menu , then Security menuitem , then Set Database Password , follow instructions .

----------


## private1337

very cool.. Thanks  :Smilie:  btw this login screen is damn cool. Is it suitable for creating code for trials to enter user name and registered code or you have alternative choices?

----------


## Pirate

Don't expect much . It's just quick demo I knocked up while practising .NET . Anyway , for copyrighting your app , you better use license component or other copy-right protection tools . The demo shows how to prevent a user who has no right to log in the program . It's easy to hack it though .

----------


## private1337

so do you have those copy-right protection tools? I also think this can be easily be hack though? is there any more security way for improve?

----------


## Pirate

There's no way to stop crackers but it can be very difficult for them to crack these tools . Just  do search on protecting software , you'll find a lot of tools and techneques .

----------


## private1337

oh.. Thanks for your information but do you have any protection tool that can recommend?

----------


## Pirate

You can use this ActiveX . It's free . There are many other ways to protect your program from crackers .Can you be more creative and invent your own way !   :Wink:  
http://www.activelock.com/about.html

----------


## private1337

> You can use this ActiveX . It's free . There are many other ways to protect your program from crackers .Can you be more creative and invent your own way !   
> http://www.activelock.com/about.html


ok thanks

----------


## angelica

Pirate,

I am developing my first project that  generates an access database which will be on a server.  Can I do something more secure than the Loginscreen.  At the moment I have something similar to Loginscreen and I wish I could make it more secure.  Do you have any suggestion.  Thanks

----------


## Pirate

SQL Server db uses mix mode authentication (Windows login & SQL Server userinfo) .I'm not sure if this applies also to MS Access db but if you're really worried about securing your db , then go for something support more security features (like SQL,Mysql...) . I don't think you can much with access .

----------


## angelica

Pirate,

Thanks for your time to help me.  As I said this is my first project and the only database I've ever used is Access. Now knowing that it is not that secure and  my project need good security now I am really considering doing it with something else like SQL Server. How can I get to know more about the SQL Server and when you said to go for more more security features (like SQL,Mysql...) what do you mean exactly.  Can you be more specific cos I need all the information I can get.  I've already desinged my database with Access but its better if I switch to something better now before I go into more work.  Thanks a loads for your help and time.

----------


## Pirate

Well, databases and security is a hot issue and can't be covered or summed up in a post and maybe you should open a new thread on this topic . 

You may start from here : http://www.microsoft.com/sql/default.mspx

----------


## cplaqui

Sir,

Hands up to people like you ! ! ! Im juz a newbie in vb .net and i found it very useful ! ! ! Im developing my 1st .net prog...Its an housing loan evaluation sheet...I think I can apply it there...

More power to you ! ! !  :Thumb:   :Thumb:   :Thumb:   :Thumb:

----------


## zen_master

awesome!

gonna need this to study...

----------


## bravo659

I downloaded your login program and works according to your coding. I tried to implement to one of my program and it crashes. Is there a way where i can use the login retrieving access database password and open the implemented program?

----------


## bravo659

I forgot to tell you that when an exception fires, it points to the sql connection.

----------


## Pirate

You should've posted your problem in one of these forums (C# or VB.NET) NOT in the CODEBANK Forum . If it's not connecting , it means something wrong with the connection string . Double check the db name , the server name ...etc . Show some code (not here ofcourse  :Big Grin: )

----------


## bravo659

Hi, I already fixed the login screen and works perfectly.

How can i change the password with a "change password button"?

----------


## zen_master

pirate, is there any way to connect to access database w/o ADO class?

may need some explanation here =)

----------


## digioz

Hey Pirate,

I hope you don't mind. I made a few changes to your login screen:

1- The actual password textbox is now masked by a " * " when you are entering it. 

2- I password protected the access datebase and changed the connection string in the code.

3- Added a login icon and change background color and login button color and text. 

4- Changed the border to fixed single so it looks more like a login. 

Great beginner example. Certainly has a lot of potential.

----------


## digioz

I just want to post a WARNING to anyone that intends to use the code in its current condition, as it is vulnerable to SQL injection in its current state. 

To demonstrate what I mean, try entering the following in the Username and Password fields:

For Username Enter: ' OR ''='
For Password Enter: ' OR ''='

Notice that the system is easily fooled into allowing access to whatever you are trying protect. This is because we are both NOT validating user input, and also using a full SQL string to query the database (instead of setting parameters).

SQL injection does NOT only work on Microsoft Access Database. It also works on ALL other database types including Microsoft SQL Server, Oracle, and MySQL to name a few. 

SO PLEASE DO NOT USE THE CODE AS IS!

----------


## angelica

hi,

Ive tried it but it doesnt open the Ms Access.  I have a program that needs a username and password and the code is similar.

what exactly is the username and password, I mean are the  '  ....' included?

----------


## digioz

Yes, you would have to type it exactly as show bellow including the single quotes:

Username: ' OR ''='
Password: ' OR ''='

What this will do is to alter the SQL query string by "injecting" the ' OR ''='
portion into where the username and password would normally go, which basically allows a hacker to bypass the login check. This is a very common method many hackers use to bypass login screens.

----------


## rguifarro

hey!   :wave:  

how can I use this example but with a sql database, instead of OleDbConnection what should be my connection string to lo into  a sql database and is it posible the make a option so that the user can change his password as many times he wants?

thanx, really need this to work.  :big yellow:

----------


## angelica

yes, you need to substitute the OLEDBconnection to SQLConnection.

As to having the user change this password you have to have a table having a USERID, Username, Password fields where the user will log in with the old password and on logging h e can use the new data and have an UPDATE command to change the old password.

If you search the forum with an update + password search Im sure you will come up with someting similar.

----------


## sammy004

Hi guys I was looking thought this and it looks interesting, however I am building a program that has many other program in it so it's accually like a menu to access other program when you hit a button that program opens up. I plan to put that program on a DVD but I wanted to know if there is any way where people can't view the files on the DVD like go into the drive right click and go to explore CD, because I don't want anyone the view the contects of the CD. If anyone can help me out please I would really appreciated.

----------


## Pirate

One way is to pack all the files in one compressed file (using your own algorithm or format) and making an index file so u would be able to know where each file starts and ends .I did something like this (for personal use)  but I was fraustrated by the slowness of unpacking the files if the file exceeded 700mb.

----------


## vip_scarface_vip

*Thanks alot MATE i having looking for this   Login Screen  1 week beacues my graduation i ask my teacher i guess he has broplem with it i dont know     any way thanks agina to help me out  sorry my English too bad    if you don't mind i want use your Example with SQL and do some change on it ...
Have nice day ty ....*

----------


## lukie123456

im new to the whole programming concept on VB I just wondered how i need to use these files to create the login i serious need a reply asap thanks alot im using version 6.5 and am doing an IT project

----------


## Pirate

> *Thanks alot MATE i having looking for this   Login Screen  1 week beacues my graduation i ask my teacher i guess he has broplem with it i dont know     any way thanks agina to help me out  sorry my English too bad    if you don't mind i want use your Example with SQL and do some change on it ...
> Have nice day ty ....*


This example was created in framework 1.1 (i think) , VS.NET 2003.I'm not sure if it doesn't work but it was when i create it.Sure you can do whatever you want to do with it .

----------


## Pirate

> im new to the whole programming concept on VB I just wondered how i need to use these files to create the login i serious need a reply asap thanks alot im using version 6.5 and am doing an IT project


Sorry man..i could only help u if you're programmer.

----------

