strSQL = "INSERT INTO Accounts UserName, Password VALUES ('" & txtUsername.Text & "', '" & txtEncryptedPassword & "');" When the code is executed and error is thrown, but there is no visible problem that i can see. Help!
The word PASSWORD is reserved in MS-Access.
You need to use square brackets around that name (Or change it to something different)
strSQL = "INSERT INTO Accounts (UserName, [Password]) VALUES (...... Said that, please use a parameterized query to build sql commands.
A string concatenation like yours is easily attacked by hackers using SQL Injection
Also, if the username or password contains a single quote, the resulting sql text built using string concatenation will be invalid.
strSQL = "INSERT INTO Accounts (UserName, [Password]) VALUES (?, ?)" OleDbCommand cmd = new OleDbCommand(strSQL, connection); cmd.Parameters.AddWithValue("@p1",txtUsername.Text); cmd.Parameters.AddWithValue("@p2",txtEncryptedPassword); cmd.ExecuteNonQuery(); You forgot parentheses:
strSQL = "INSERT INTO Accounts (UserName, Password) VALUES ('" & txtUsername.Text & "', '" & txtEncryptedPassword & "');" try this code:
Dim strSQL As String = "INSERT INTO tblDetail VALUES('" & strPersonCode _ & "','" & strForename & "','" & strSurname & "','" & strDateOfBirth & "'," & strCurrentlyWith & ",'" & strConditions & "')" Do it like that but change to your names. Declare the values of text boxes as strings and just use those.
your doing () this mistake and you should must add:
your code:
strSQL = "INSERT INTO Accounts UserName, Password VALUES ('" & txtUsername.Text & "', '" & txtEncryptedPassword & "');" you should must change code following as:
strSQL = "INSERT INTO Accounts (UserName, Password) VALUES ('" & txtUsername.Text & "', '" & txtEncryptedPassword & "');" update1:
"INSERT INTO `test`.`users` ( `username`, `password`) " & _ "VALUES ('" & txtUsername.Text & "', '" & txtPassword.Text & "');" update2:
"INSERT INTO users ( `username`,`password`)VALUES(@txtUsername.Text,@txtPassword.Text);" "INSERT INTO users (Username,Password)VALUES(?,?);" note:test means database name you should change your databasename.
... INTO Accounts (UserName, Password) ...