what is wrong with this code?

electronik54

Member
Licensed User
Longtime User
:sign0085::sign0104: :sign0085::sign0104:

Sub clear_confirm_click

If SQL2.IsInitialized = False Then
SQL2.Initialize(File.DirDefaultExternal, "userdata.db", true)
End If

Dim Position As Int
Dim Findrow As Int = Position
Dim cursor12 As Cursor
cursor12 = SQL2.ExecQuery("Select u_pass FROM login_data")
cursor12.Position = Findrow

Then
If E_entr_pass.Text.Contains("")=True Then


If E_entr_pass.Text=""&cursor12.GetString("u_pass") Then
ToastMessageShow("App resetted",False)
File.Delete(File.DirDefaultExternal,"userdata.db")

Else
ToastMessageShow("Wrong Password",False)
End If

Else
ToastMessageShow("Enter Password",False)
End If
cursor12.Close
End Sub

file wont be deleted even when <<E_entr_pass.Text=""&cursor12.GetString("u_pass")>>
 
Last edited:
Is there an error in the log or full log? (Uncheck the filter in the log tab). It wouldn't surprise me if it won't let you delete a file that is still open.
 
Upvote 0
I can see one things wrong just by looking at the code.
#1 in this code
Code:
If E_entr_pass.Text.Contains("")=True Then


If E_entr_pass.Text=""&cursor12.GetString("u_pass") Then
ToastMessageShow("App resetted",False)
File.Delete(File.DirDefaultExternal,"userdata.db")

Else 
ToastMessageShow("Wrong Password",False)
End If

Else 
ToastMessageShow("Enter Password",False)
End If   
cursor12.Close

notice on this line
If E_entr_pass.text = "" & cursor12.getstring("u_pass")

you're not comparing the cursor12.getstring("u_pass") to anything, therefore everthing inside this IF Statement never gets executed, that is why the file never gets deleted.

the correct format would be like this:

Code:
If E_entr_pass.text = "" & cursor12.getstring("u_pass") = "" then
'rest of your code goes here


Give it a try!
 
Upvote 0
I can see one things wrong just by looking at the code.
#1 in this code
Code:
If E_entr_pass.Text.Contains("")=True Then


If E_entr_pass.Text=""&cursor12.GetString("u_pass") Then
ToastMessageShow("App resetted",False)
File.Delete(File.DirDefaultExternal,"userdata.db")

Else 
ToastMessageShow("Wrong Password",False)
End If

Else 
ToastMessageShow("Enter Password",False)
End If   
cursor12.Close

notice on this line


you're not comparing the cursor12.getstring("u_pass") to anything, therefore everthing inside this IF Statement never gets executed, that is why the file never gets deleted.

the correct format would be like this:

Code:
If E_entr_pass.text = "" & cursor12.getstring("u_pass") = "" then
'rest of your code goes here


Give it a try!

Parsing code. 0.02
Compiling code. Error
Error compiling program.
Error description: 'Then' expected.
Occurred on line: 868
If E_entr_pass.text = "" & cursor12.getstring("u_pass") = "" Then
Word: =
 
Upvote 0
the code i posted above actually works

the code i posted above actually works the problem was some where else.

here is the actual problem

userdata.db in <Assets> is copied to <DirDefaultExternal> which is empty initially. it contains TWO tables 1.for username and password 2.for phone_num
the code actually deletes the DB. when the other part of my program copies userdata.db from <Assets> to <DirDefaultExternal> the <username>table is updated(or empty) BUT <phone_num>table retrieves the old values.

any idea how can this happen? is getting the old values from the edittext(which is used for getting values to add to DB)
 
Upvote 0
Back
Top