Database Connection and Login Form Visual Basic 6 Tutorial
2. Select Standard EXE. A project will be created with a default form1 on it.
3. To use ADDODB connection, select Project>References and check Microsoft Active X Data Objects 2.8 Library
4. Add a new module for the database connection string
5. Select Open and add this following code on the module you just added
Public dbconnect As New ADODB.Connection
dbconnect.CursorLocation = adUseClient
dbconnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\sample.mdb" 'MS access database connection string
If dbconnect.State = adStateOpen Then 'check if database connection is successful
MsgBox "Successfully connected to the database"
Form1.Show 'after connecting to the database form1 will show
MsgBox "database connection failed"
6. Right click on the Project and select Project Properties
Change the Startup Object from form1 to Sub Main and click OK. This way the sub main will execute first
7. On form 1, put the necessary textboxes, label and command button for login form.
8. Double click on login button and paste the following code
Private Sub Command1_Click()
Dim rslogin As New ADODB.Recordset 'declare a new recordset that will hold the value of the database connection
rslogin.Open "Select * from tuser where username = '" & Text1.Text & "' and password = '" & Text2.Text & "'", dbconnect, adOpenKeyset, adLockOptimistic 'open the database connection and check if the username and password exist on the tuser table
If rslogin.RecordCount <> 0 Then 'if record exist then
MsgBox "Login success"
'you can add code here like mdimain.show and unload the login form
MsgBox "invalid username/password"
9. After this you can add mdiform for your main form and any other form.
More by this Author
Important: This counter strike cheats works and tested on version 1.3. Just try this if it will work on higher version of counter strike. To activate cheats, type in the console sv_cheats 1 Then type restart. After...
No comments yet.