Results 1 to 16 of 16

Thread: Databases

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    34

    Question 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

    thanks in advance

  2. #2
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: Databases

    Well, what have you tried so far ¿ Do you have any code already ¿
    VB.NET MVP 2008 - Present

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    34

    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

  4. #4
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    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.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    34

    Re: Databases

    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

  6. #6
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    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.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    34

    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

    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

  8. #8
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    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
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  9. #9

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    34

    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...
    Last edited by Z_Dub; Feb 9th, 2010 at 10:42 AM.

  10. #10
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    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.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  11. #11

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    34

    Re: Databases

    i didnt expect anyone to code anything for me...

  12. #12

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    34

    Re: Databases

    hes using vs 2005, there isint a System.Data.OleDb namespace in 08...

    I guess ill figure it out eventually...

  13. #13
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Databases

    Sure works for me in 2008

    Imports System.Data.OleDb
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  14. #14

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    34

    Re: Databases

    i cant find it... where did you find it?

  15. #15
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Databases

    I just write Imports System.Data.OLEDB at the top of the code for a form.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  16. #16
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    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.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width