This seems really stupid seeing as they are used so often but how do i create a database using vB 4.0? I am creating a login form and when the command button is hit it compares the username and encrypted password to the stored username and encrypted password, if its a match it continues to the next form, if not it spits out an error, can anyone help?

Dani AI

Generated

Several people here already sketched workable directions—, and suggested a file-based .mdb route, and offered a flat-file alternative. For a login system the critical choices are (1) how you store credentials, (2) how the app accesses that store, and (3) how you deploy it so the app can read/write the file on target machines. Pick the simplest storage you can deploy reliably, but design the credentials properly.

Security first: do not store reversible encrypted passwords or plaintext. Store a per-user salt plus a one-way hash (use a modern KDF where possible: bcrypt/Argon2/PBKDF2). If those aren't available in your VB environment, perform hashing in a small helper component or on a server, or at minimum use SHA-2 with many iterations and a unique salt per user. Always use parameterized queries for lookups (never build SQL with string concatenation) to avoid injection.

Practical VB6/VB4 pattern (illustrative): retrieve the stored salt/hash for the typed username, compute the hash of the entered password plus that salt, then compare. Example (assumes ADO available and a helper ComputeHash function):

' requires reference to Microsoft ActiveX Data Objects
Dim cn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
Dim storedHash As String, storedSalt As String, inputHash As String

Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Path\Users.mdb;"

Set cmd = New ADODB.Command
With cmd
  .ActiveConnection = cn
  .CommandText = "SELECT PasswordHash, Salt FROM Users WHERE Username = ?"
  .CommandType = adCmdText
  .Parameters.Append .CreateParameter("p1", adVarChar, adParamInput, 50, txtUsername.Text)
  Set rs = .Execute
End With

If Not rs.EOF Then
  storedHash = rs!PasswordHash
  storedSalt = rs!Salt
  inputHash = ComputeHash(txtPassword.Text & storedSalt) ' implement securely
  If inputHash = storedHash Then
    ' authenticated
  End If
End If

Deployment/troubleshooting tips: put writable DB files in a proper app data location (not a protected folder), ensure file permissions for writes, and include any required runtime providers on target machines. For multi-user or stronger security, use a server database (SQL Server Express, MySQL, or a modern embedded engine like SQLite) or move auth logic to a server-side service.

Recommended Answers

All 8 Replies

You can use data control in the default tool box and your database is stored in access file just use the properties of the data control i.e. the databasename to locate the .mdb file and recordesource to work with any specified table from your database


i Hope this helps

You can use data control in the default tool box and your database is stored in access file just use the properties of the data control i.e. the databasename to locate the .mdb file and recordesource to work with any specified table from your database


i Hope this helps

is there no way to create the database so that the program can access and use it without having M$ access? Its just the program i am writing I would usually use M$ access but the user doesn't have M$ access this time or any other database programs so i was rather hoping there would be a way to use databases using vB only.

They don't need access. the jet engine is in MDAC and thats included with win98 / 2000 / nt and xp so your VB app can access an mdb file even if the pc doesn't have MS Access on it.

You don't need a database for that. You could use a flat file, so long as you encrypt the password. Most of these "password files" are set up in the old unix fashion, where each username / password combination is stored on 1 line in the file (so if you had 10 users, you'd have 10 lines in the file). The username and the password would be separated by a delimiter (usually colon), and then split at the time of the read, so something like this:

comatose:myencryptedpassword
hollystyles:hisencryptedpassword
keratinimp:yourencryptedpassword

Then, when the user types in the username and the password, you encrypt the password that they just typed in, the EXACT same way as you encrypted the password they typed in for the file. If the two encrypted passwords are the same, then they are good to go (and if the usernames are the same).

u can use visdata to make a database.. access isnt needed to be present in ur comp. to open visdata: click as follows
addin>visual data manager. visdata wud be open.
then click
file>new>microsoft access> version X.0 MDB (X is the digit u wud prefer)
and then its pretty straight forward.

Cool.

*Adds it to his list of "things"*

Hi, I myself am a complete novice, but i am also working on a database program similar to what you describe. Please download this project and you will see what is needed. Hope this helps you . Bill

Sorry i forgot to mention that you may get an error message somthing like " object not found " this will be because the database file, .MDB file is not included in the zip. You would make your own data base file in VB. I thing if i remeber correctly i named mine Phone.mdb
Hope that made sense. Bill

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.