This is part of my login form.

im trying to lock the account if there are to many failed login attempts. but im not sure if my sql statement is wrong or i my ExecuteNonQuery() is wrong.

heres part of my code. I should note that my "account_lock" column is a "Yes/No" column in access.

If FailAttemps = 6 Then
                    MessageBox.Show("6 Failed Login Attemps, This Account is Now Locked." _
                    + "Please Contact an Admin to Unlock This Account.", "Failed Login", MessageBoxButtons.OK, MessageBoxIcon.Information)

                    Dim UpdateAccountLock As String = "UPDATE employee SET account_lock = '1' WHERE username = '" & UsernameTextBox.Text & "'"
                    DBconnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Login.accdb")
                    DBconnection.Open()
                    Dim LoginFailCommand As OleDbCommand = New OleDbCommand(UpdateAccountLock, DBconnection)
                    LoginFailCommand.ExecuteNonQuery()
                    Form1.Close()
                    Me.Close()

                    DBconnection.Close()
                    DBconnection.Dispose()

So, what happened? exception raises? or it closes the form normally?, I can't admit that MySQL query is correct but it's ANSI-SQL all RDBMS should support it.

So, what happened? exception raises? or it closes the form normally?, I can't admit that MySQL query is correct but it's ANSI-SQL all RDBMS should support it.

There's no error when i run the program, but when i check the database or re-run the program to check if the account gets locked, the data base doesn't get updated, so the account is locked.

so i've found out Access boolean ordinals are 0(No/False) and -1(Yes/True). but changing to -1 doesn't help.

In access the columns data type is yes/no, and the format was yes/no so i changed the format to true/false (which was something i didn't notice before) set the default value to false. nothing helped tho.

yes i've tired it every which way. '-1' , -1, True , 'True' although only 'True' gives me this error

"data type mismatch in criteria expression"

i've read the access basics tutorial at dream in code and im doing the update SQL statement pretty much the same way as in the tutorial. So i don't understand why it wont update the stupid database.

"data type mismatch in criteria expression"

because you should pass integral value.
So, Doesn't MySQL have profile to log the coming connection\transaction like MS SQL? you can check it, or I do recommend you to use MySQL library for .NET which on http://MySQL.org instead of OLE

because you should pass integral value.
So, Doesn't MySQL have profile to log the coming connection\transaction like MS SQL? you can check it, or I do recommend you to use MySQL library for .NET which on http://MySQL.org instead of OLE

The topic starter uses MS ACCESS database not MySQL nor MS SQL so the problem he gets is specifically from MS ACCESS exceptions.

In MS Access you can simply put TRUE or FALSE for your BOOLEAN fields. Do not put any quotes.

I got confused because they mentioned "my sql statement" I didn't recognize they mean: "their sql statement"

I take it no one see anything wrong with my code?

even with account_lock = True it doesn't work. it doesn't give me any errors, yet it doesn't update the database. i've seen others code doing updates on access databases and its pretty much the same. i don't get why its not working.

Look try just to update field "Lock" by "ID" instead of by username.

I bookmarked this already dude great work

Regards

Jenifier

Lol, Never mind, I fixed it. well there was actually nothing wrong. My dumb butt was looking in the wrong database. i keep checking the database in the project folder, when i needed to be checking the database in the bin/debug folder.

thanks for the help tho.

You're welcome please mark it as solved.

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.