I'm doing a program and I'm in a part that I need to create users in the database in access. But after entering the data and clicking the create user button it gives me an error. If you add users to the database it works but if you try to add it by the program's the result is a syntax error
Else
Try
Dim myconnection As OleDbConnection
Dim constring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\Software_Simples\Software\DataBase.accdb"
myconnection = New OleDbConnection(constring)
myconnection.Open()
Dim sqlQry As String
'sqlQry = "INSERT INTO Usernames(Username, Password) VALUES(" & TextBox2.Text & "," & TextBox3.Text & ")"
sqlQry = "INSERT INTO Usernames(ID_User, Username, Password) VALUES(Null,TextBox2.Text,TextBox3.Text )"
Dim cmd As New OleDbCommand(sqlQry, myconnection)
cmd.ExecuteNonQuery()
myconnection.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'Fechar
Me.Close()
MessageBox.Show("Utilizador criado com suecesso: " & username_create, "Aviso", MessageBoxButtons.OK)
End If