SELECT * FROM users WHERE user = ? AND password = ?
"SELECT * FROM `users` WHERE `username`='" & TxtUsername.Text & "' AND `password`='" & TxtPassword.Text & "'"
Sub JobDone(Job As HttpJob)
Dim LoginStatus As Int
LoginStatus=0
' Msgbox(LoginStatus,"Value")
If Job.Success = False Then
Log("Error: " & Job.ErrorMessage)
Else
If Job.JobName = "DBRequest" Then
Dim result As DBResult = reqManager.HandleJob(Job)
If result.Tag = "login" Then 'query tag
reqManager.PrintTable(result)
If result.Rows.size > 0 Then
LoginStatus=1
' Msgbox("Valid user "& LoginStatus,"Login successful")
StartActivity("Search")
Else
LoginStatus=0
Msgbox("Invalid user "& LoginStatus,"Login UnSuccessful")
End If
End If
End If
End If
' Job.Release && This line errors out
' Msgbox(LoginStatus,"Value")
' If LoginStatus = 1
' StartActivity("Search")
' End If
Job.Release
End Sub
Job.Release ' Job.Release should be done first, so that the memory is free and the user moves to the second activity screen
StartActivity("Search")
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private btnSearch As Button
Private edtSearchWord As EditText
Private lvLocationList As ListView
Private spnSearchType As Spinner
Dim SelectedSrchType As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Search")
If FirstTime Then
spnSearchType.Add("ItemCode wise")
spnSearchType.Add("ItemName wise")
spnSearchType.SelectedIndex=0 'Make the first item as selected by default
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnSearch_Click
If edtSearchWord.Text = "" Then
Msgbox("Please enter the item to search","Invalid search")
Else
searchparts(edtSearchWord.Text)
End If
End Sub
Sub spnSearchType_ItemClick (Position As Int, Value As Object)
SelectedSrchType=Value
End Sub
Sub searchparts(SearchString)
Msgbox(SearchString,"SearchString Val")
Dim cmd As DBCommand
cmd.Initialize
cmd.Name="select_parts"
cmd.Parameters=Array As Object(SearchString)
Main.reqManager.ExecuteQuery(cmd, 0, "search")
End Sub
Sub JobDone(Job As HttpJob)
Msgbox("reached JobDone","Test") ' This is not getting executed
If Job.Success = False Then
Log("Error: " & Job.ErrorMessage)
Else
If Job.JobName = "DBRequest" Then
Dim result As DBResult = Main.reqManager.HandleJob(Job)
lvLocationList.Clear
If result.Tag = "search" Then 'query tag
Main.reqManager.PrintTable(result)
Msgbox(result.Rows.size,"No of records")
For Each records() As Object In result.Rows
lvLocationList.AddSingleLine( records(result.Columns.Get("Branch_Code")) & ":" & records(result.Columns.Get("Curr_Qty")) )
lvLocationList.SingleLineLayout.ItemHeight=40
lvLocationList.SingleLineLayout.Label.TextSize=20
lvLocationList.SingleLineLayout.Label.TextColor=Colors.Black
lvLocationList.SingleLineLayout.Label.Color=Colors.White
Next
Msgbox("Data loaded", "see this")
End If
End If
End If
Job.Release
End Sub
NO! NOT suddenly...Now, when I run my app, what happens is that after the user typed the search item in the EditText and clicks the "Search" button my app suddenly goes back to the previous screen ie the login screen.
Sub searchparts(SearchString)
Msgbox(SearchString,"SearchString Val")
Dim cmd As DBCommand
cmd.Initialize
cmd.Name="select_parts"
cmd.Parameters=Array As Object(SearchString)
Main.reqManager.ExecuteQuery(cmd, 0, "search")
End Sub
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private reqManager AS ...........
End Sub
Sub Activity_Create(FirstTime AsBoolean)
If FirstTime Then
reqManager.Initialize(Me, "http://192.168.0.100:17178")
End If
End Sub
Sub JobDone(Job As HttpJob)
Dim LoginStatus As Int
LoginStatus=0
' Msgbox(LoginStatus,"Value")
If Job.Success = False Then
Log("Error: " & Job.ErrorMessage)
Else
If Job.JobName = "DBRequest" Then
Dim result As DBResult = reqManager.HandleJob(Job)
If result.Tag = "login" Then 'query tag
reqManager.PrintTable(result)
If result.Rows.size > 0 Then
LoginStatus=1
StartActivity("Search") ' Is this the right way?. So what happens to the Job.Release ?
Else
LoginStatus=0
Msgbox("Invalid user "& LoginStatus,"Login UnSuccessful")
End If
End If
End If
End If
' My idea was to use a variable to store a value to understand whether the login was successful or not
' ie
' If result.Rows.size > 0 Then
' LoginStatus = 1
' Else
' LoginStatus = 0
' End If
' Job.Release && But calling Job.Release before StartActivty gives compile error
' If LoginStatus = 1 Then
' StartActivity("Search")
' Else
' End if
Job.Release
End Sub
' Is there any way to return a value from Sub JobDone ?
I did not tell something other. You CAN access them and you DID and get no error. But you need to know about what happens when you start a http job (the job done is raised on that activity where the job is started from). THIS you must always have in mind...I thought that whatever declared in Sub Process_Globals is Global/Public variable and can be accessed from all other modules including other Activities too
No. You are calling an RDC. The RDC (on server side) opens the db, retrieve and post back the data and then rdc closed the connection to the database. You dont need to close in your app (as you did NOT open any database)So is there any way OR is there a need to close these database connections when we quit the program. If we are supposed to close the connection to the database, then how we do it ?.
In other programming languages, we establish a connection to the database during the program start and maintain that connection object till we quit the application. While we quit the application, we disconnect the connection object from the database and free the used resources. Is there such need here in Android and B4A ?
So what happens to the Job.Release ? Is this the right way ?
Sub JobDone(Job As HttpJob)
' Do whatever you need to do here...
' You can start a new activity for ex.
'
' NOTE that the next line must ALWAYS be the last command in your job done sub....
' Remember that you dont need to care about open databases as the rdc is resposive for that.
'
' But YOU are responsive to free the memoy the jobs uses with job.Release
Job.Release
End sub
Dont say "i got an error" and then you did NOT post the error you got! That´s the wrong way to get help from us.If I do Job.Release and then call StartActivty() then it gives compilation error.
Addition:NOTE that the next line must ALWAYS be the last command in your job done sub...
Now, when I run my app, what happens is that after the user typed the search item in the EditText and clicks the "Search" button my app suddenly goes back to the previous screen ie the login screen. I beleive that this is something wrong with the way that I am coding.
The above statement made by me is wrong. I tried calling Job.Release first, then called StartActivity("SecondActivity") and found that it is working fine. I assume that I might have went wrong somewhere else. I am really sorry. I am correcting it here so that it doesn't mislead other newbies.If I do Job.Release and then call StartActivty() then it gives compilation error.
Problem No 1:
Another issue faced is that after successful login, I move to the second activity. I don't want my user to go back to the initial login page again by pressing the back button from the second activity. In fact it is not right to go back to the login page once again after the user already logged in successfully.
I don't know how to control this. What I need is that, from the second activity, if the user press the back key, then the App should ask the user whether to Exit the app or not. If the user opted to exit the app then I need to quit the app without going back to the previous screen ie the login screen.
If the app asked the user "Exit the App ? Yes OR No ?" and if the user opted No, then the app should remain in the same screen
[..]
Activity.Finish
Startactivity(second)
Job.Release
end sub
sql.select_itemnames=SELECT Item_code, item_description FROM items_master WHERE item_description LIKE '%?%';
reqManager.PrintTable(result)
sql.select_itemnames=SELECT Item_code, item_description FROM items_master WHERE item_description LIKE '%?%';
sql.select_itemnames="SELECT Item_code, item_description FROM items_master WHERE item_description LIKE '%spring%'"
sql.select_itemnames="SELECT Item_code, item_description FROM items_master WHERE item_description LIKE '%spring%'"
sql.select_itemnames=SELECT Item_code, item_description FROM items_master WHERE item_description LIKE '%spring%'
sql.select_itemnames=SELECT Item_code, item_description FROM items_master WHERE item_description LIKE '%?%'
reqManager.PrintTable(SqlStatement)
sql.select_itemnames=SELECT Item_code, item_description FROM items_master WHERE item_description LIKE '%?%'
SELECT Item_code, item_description FROM items_master WHERE item_description LIKE '%spring%'
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?