I am using an access database and have the tables 'Users'. Within that table I have the fields 'Username' & 'Password'. The problem occurs when I try to execute a non query command to check if the record has been added. The code for the account addition is below:
If TextBox1.Text = "" Then
MsgBox("An account username must be provided.", MsgBoxStyle.Exclamation, "Error")
If TextBox2.Text = "" Then
MsgBox("An account password must be provided.", MsgBoxStyle.Exclamation, "Error")
Dim cmd As New OleDbCommand(addsql, conn)
MsgBox("The new account " & "'" & TextBox1.Text & "'" & " was saved successfully!", MsgBoxStyle.Information, "Account Saved")
The global variables are all in the code below:
Public mypath As String = Application.StartupPath & "\Data\Database.mdb"
Public mypassword As String = ""
Public conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mypath & ";Jet OLEDB:Database Password=" & mypassword)
Public cmd As OleDb.OleDbCommand
Public addsql As String = "INSERT INTO Users (Username, Password) VALUES ('" & Accounts.TextBox1.Text & "','" & Accounts.TextBox2.Text & "')"
Don't know why it is not working, it works with my other application.