i am a beginner, how to authenticate username and password to the database

i hope i'll be responded soon

Recommended Answers

All 3 Replies

What kind of database? What is your level of expertise with databases/VB? Do you mean a process like

get username and password from text fields on a form
compare to list of valid usernames and passwords from the database

if username and password were found in the database
    let user continue with application
else
    display invalid username/password and close application
end if

If that is the case then what do you need to know? Do you know how to connect with the database? Do you know the basics of doing a SQL query?

how to connect to the database plz

What kind of database? What is your level of expertise with databases/VB? Do you mean a process like

get username and password from text fields on a form
compare to list of valid usernames and passwords from the database

if username and password were found in the database
    let user continue with application
else
    display invalid username/password and close application
end if

If that is the case then what do you need to know? Do you know how to connect with the database? Do you know the basics of doing a SQL query?

You connect to the database by a connection object. The value of the connection string property will depend on the type of database and the type of security. For example, to connect to a database on a local SQLEXPRESS using integrated security (where you are validated based on who you logged in to Windows as), the connection string might be

Driver={SQL Server};Server=jim-pc\sqlexpress;Database=NorthWind;Trusted_Connection=yes;

If, on the other hand, you are logging in based on a SQL account (set up by the database administrator) you would use the string

Driver={SQL Server};Server=jim-pc\sqlexpress;Database=NorthWind;Uid=USERNAME;Pwd=PASSWORD;

in both cases you would substitute the appropriate values for the server, database, username and password. In my example I used the sample NorthWind database. If you are connecting to an Access database your string is

Driver={Microsoft Access Driver (*.mdb)};Dbq=ACCESSFILENAME;Uid=USERNAME;Pwd=PASSWORD;

There are other connection strings for Sybase, Excel, XML, etc. If your connection object is called CONN then you open the connection by

conn.ConnectionString = "one of the above connection strings"
conn.Open

If conn.State = 1 Then
    'your connection has been established
Else
    'your connection has been denied
End If

There are other ways of connecting. My preference is to use ADO (which is what I specified above). There may be better ways now but this is what I learned and it has worked for me for the last decade or so.

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.