I'm trying to connect a database with a login form to verify user as an existing one or a new one to sign up

Private Sub Command1_Click()
Adodc1.RecordSource = "select *from newcustomer where firstname='" + Text1.Text + "' and surname='" + Text2.Text + "' and customerid='" + Text3.Text + "' and phone='" + Text4.Text + "' and yearofbirth='" + Text5.Text + "' and emailaddress='" + Text6.Text + "' and username='" + Text7.Text + "' and password='" + Text8.Text + "' "
Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox "INVALID USERNAME/PASSWORD"
Else
Form4.Show
End If
End Sub

Private Sub Command2_Click()
Adodc1.Recordset.Update
End Sub

Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
End Sub

customer login code

Option Explicit
Private HiddenPassword As String
Private UserName As String
Private Pressed(100) As String
Private ChrValues(100) As String
Private G As String, UserNameLength As String
Private B As Integer, PasswordLength As Integer
Private EnteredValues As String
Private Const UserNameValue = "Enter Your UserName!!!"
Private Const PasswordValue = "Enter Your Password!!!"
Private Sub cmdCancel_Click()
    'set the global var to false
    'to denote a failed login
    End
    'LoginSucceeded = False
    Me.Hide
End Sub

Recommended Answers

All 4 Replies

I'll add that in a current job I'm working on is in VB6 and the database connector is dead. I do have an ugly workaround but we opted to just create report files rather than continue with any database use in the now decades old app.

-> Let me restate this. The database connector in VB6 is dead. It's time to move on if you want the old ADO and other database connections.

Don't use the Data Control.
Here is an example (not using a Data Control) from vb-helper -
If you go to this link you can download the project
http://www.vb-helper.com/howto_ado_use_access_password.html

Private Sub cmdOpen_Click()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset

' Open the connection.
Set conn = New ADODB.Connection
conn.ConnectionString = _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Me.txtDbName.Text & ";" & _
    "Jet OLEDB:Database Password=" & txtPassword.Text
conn.Open

' Get the data.
Set rs = conn.Execute("SELECT Title FROM Books ORDER BY " & _
    "Title")
lstTitles.Clear
Do While Not rs.EOF
    lstTitles.AddItem rs!Title
    rs.MoveNext
Loop

rs.Close
conn.Close

End Sub

Hope this helps,
Rob

commented: That seems to be OK pre-Windows 10. Client demanded old app installs and runs on W10 so no ADO now. +15

I am noticing a few threads WRONGLY saying that VB6 Data Base (ADO) apps do not work in W10.
That is INCORRECT.
They run fine.
If you have been using Dependencies (eg Data Environment OR Data Control) unnecessarily you may have problems.
That is why I have avoided such dependencies for years.
If you use pure ADO code, then your database applications will run perfectly in W10 (mine all do, and they are all being used in W10)

commented: Thanks for clarifying that. Since every app I run into used Dependencies, all are dead now. +15
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.