-
Databases
lately, ive had a lot of free time and have been trying to password protect my flash drive in VB 2008. and ive figured out almost everything i want with it, but ive come to a bit of a roadblock. as of right now, ive got 2 accounts, but thats all ive done so far, because every account has like 3 if statements, and it would start to accumulate a bit of i made anymore. so, ive been looking into using a database, and having it retrieve the password and username from there. ive searched for hours, and have found a lot of little bits and pieces of code, but nothing that would work for my situation. Will somebody tell me how i would:
1: make sure that the password and username match in the database when i click the confirm button
2: add a new username and password to a database when they want to make their own account
3: save changes to the database when i log out and move to another computer
also, is there a simple way to log the date, time, IP address, and Username, put it in a text file, and email it to me? i would also like to know how to open a flash drive using its name, and not its letter, cause its a different drive letter on different computers.
please dont give me a link to another thread or website, chances are ive already been there :p
thanks in advance :wave:
-
Re: Databases
Well, what have you tried so far ¿ Do you have any code already ¿
-
Re: Databases
as of right now, ive got this for each user. Ive got to make 3 of each for all the different drive letters that the drive will be on different computers
Code:
If (txtuser.Text = "Zack") And (txtpass.Text = "password") And (cmbdrive.SelectedItem = "E:") Then
ChDir("E:")
Dim sh
sh = CreateObject("WSCript.Shell")
sh.Run("E:")
sh = Nothing
End
ElseIf (txtuser.Text = "Zack") And (txtpass.Text = "password") And (cmbdrive.SelectedItem = "F:") Then
ChDir("F:\")
Dim sh
sh = CreateObject("WSCript.Shell")
sh.Run("F:\")
sh = Nothing
End
ElseIf (txtuser.Text = "Zack") And (txtpass.Text = "password") And (cmbdrive.SelectedItem = "J:") Then
ChDir("J:\")
Dim sh
sh = CreateObject("WSCript.Shell")
sh.Run("J:\")
sh = Nothing
End
and i also have a database with two colums, one for username and one for password, i just need to figure out how to use that database with vb, and have it search for a password and match it to the username, and be able to add a user whenever i want by adding it to the database and get rid of all these annoying if statements
-
Re: Databases
Why all the if statements. You store the UserName, Password and DriveLetter in a database.
1. You ask for the username and password on a login form.
2. You query the UserTable in the database selecting the DriverLetter where the UserName = the username on the form and the Password = the password on the form.'
3. If you get data back you have the drive letter if not the user entered invalid data.
-
Re: Databases
:ehh: thats what im trying to figure out how to do, i have a database, how do i attach it to my program and make sure the user and password match in the database? what would my code look like assuming the database was named log in
thanks for the quick reply :)
also, in the last 5 minutes, ive hit another small problem, how do i disable a cursor clip on the main form so i can enable it on another form? its probably embarrassingly simple
-
Re: Databases
One question per thread only. Start a new one for the other question.
Have you looked at the Database FAQs? There is a complete tutorial there for connecting to a database and getting results.
-
Re: Databases
yeah i searched database and nothing came up, same for databases
if i told you all the problems i had each in a new thread, the entire page would be filled up with them :p
i was taking visual basic about a year ago, but it was too small, so they collapsed it, i tried again, and it was still too small, so my teachers got really POed and put me in indipendent study, im the only one in the class, and the teachers gotta teach other classes, so all ive got is this book, which dosen't provide much info :sick:
-
Re: Databases
You need to read the FAQ area
Step 1: http://www.vbforums.com/showthread.php?t=466658
Step 2: http://www.vbforums.com/showthread.php?t=469872
Both of these threads will anwser your question
-
Re: Databases
when i go to FAQ, type in Database, select match any words, i get this
also, that looks like it was made in 07, ive got vb 2008, isint there a bit of a difference? cause the sample there didnt work...
-
Re: Databases
When you click on Database Development on the main page you get to see this:
Sticky: Database Development FAQs & Tutorials [updated Mar 26]
IF you click on that link you go here
http://www.vbforums.com/showthread.php?t=337051
IF you read down the page there you will find the threads I posted. Read them.... Attemp to code what the show you.... If you have issues with a section of code post the code you wrote. What Line the error occurs on. What the error message is... What the database you are using is.
That is what will get you answers. I work for a living doing this, I can't code it for you.
-
Re: Databases
i didnt expect anyone to code anything for me...
-
Re: Databases
hes using vs 2005, there isint a System.Data.OleDb namespace in 08...
I guess ill figure it out eventually... :p
-
Re: Databases
Sure works for me in 2008
Imports System.Data.OleDb
-
Re: Databases
i cant find it... where did you find it?
-
Re: Databases
I just write Imports System.Data.OLEDB at the top of the code for a form.
-
Re: Databases
You actually shouldn't even need to do that. I never do, and I am currently using the OLEDB namespace in VS2008. Of course, I just fully decorate my names, for instance, a command object is:
Dim cmd As Data.OleDb.OleDbCommand
I guess that's not FULLY decorated, as I left off System, but it should be enough. If you don't get OleDB as an option in intellisense when you type Data., then something is a bit off.