Hello :) I'm a newbie in VB.NET and I'm trying to create a 'create account' form. However like what I put in the codes, whenever I try to debug, it keeps saying Failed to connect to database? Can somebody tell me what's wrong thank you
Public Class Form2
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            ' Check if username or password is empty
            If TextBox1.Text = "" Or TextBox2.Text = "" Then
                MessageBox.Show("Please complete the required fields.", "Authentication Error!", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Else
                ' Both fields was supply
                ' Check if user exist in database
                ' Connect to DB
                Dim conn As New System.Data.OleDb.OleDbConnection()
                conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Thesis\Thesis\Database2.accdb"
                Try
                    'conn.Open()
                    'MsgBox("Susscess")
                    Dim sql As String = "INSERT * INTO tbl_user WHERE username='" & TextBox1.Text & "' AND password = '" & TextBox2.Text & "'"
                    Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql)
                    'Open Database Connection
                    sqlCom.Connection = conn
                    conn.Open()
                    Dim sqlRead As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()
                    If sqlRead.Read() Then
                        Form3.Show()
                        Me.Hide()
                    End If
                Catch ex As Exception
                    MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End Try
            End If
        End Sub
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Me.Hide()
            Form1.Show()
        End Sub
        Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        End Sub
        Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
        End Sub
    End Class
 
     
    