Android Question error when enterpressed textbox

jamir

Member
hello everybody
can help me...

this myTable

CodeItem, ProdName
000001, Bread
000002, egg

example, when i fill the codeitem textbox with type "000001" and then ENTER
the ProdName textBox will show "Bread"

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim SQL1 As SQL
Dim Csr1 As Cursor
End Sub

Sub edtcditem_EnterPressed
mdlConn.CSR1=mdlConn.SQL1.ExecQuery("select * from myTabel where PartCode = '" & edtCdItem.Text & "'")
If mdlConn.CSR1.RowCount > 0 Then
ToastMessageShow("The Item is Found...",True)
edtProdName.Text = CSR1.GetString("ProdCode")
Else
ToastMessageShow("the Item Not Found",True)
End If
End Sub

its always error, when i try running affter fill type the code item textbox

but when i delete/non active the sintaks ( Bold text ), is succes running

any solution .... ?? thx :)
 

Attachments

  • test1.jpg
    test1.jpg
    12.1 KB · Views: 138
  • test2.jpg
    test2.jpg
    21.5 KB · Views: 134

jamir

Member
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
    Dim SQL1 As SQL
    Dim Csr1 As Cursor
End Sub

Sub edtcditem_EnterPressed
    mdlConn.CSR1=mdlConn.SQL1.ExecQuery("select * from myTabel where PartCode = '" & edtCdItem.Text & "'")
    If mdlConn.CSR1.RowCount > 0 Then
        ToastMessageShow("The Item is Found...",True)
        'edtProdName.Text = CSR1.GetString("ProdCode")
    Else
        ToastMessageShow("the Item Not Found",True)
    End If
End Sub
 
Upvote 0

jamir

Member
im sorry, im repeat my message

Table
MasterData
SKU, Name
000001, Bread
000002, egg

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim SQL1 As SQL
    Dim Csr1 As Cursor
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 lblKode As Label
    Private edtKode As EditText
    Private lblProdName As Label
    Private edtProdName As EditText
    Private lvDtMaster As ListView
End Sub

Sub edtKode_EnterPressed
    mdlconn.CSR1= mdlConn.SQL1.ExecQuery("select * from MasterData where SKU = '" & edtKode.Text & "'")
    If mdlConn.CSR1.RowCount > 0 Then
        'Csr1.Position = 0
        ToastMessageShow("Found",True)
        edtProdName.Text = Csr1.GetString("Name")
    Else
        ToastMessageShow("Not Found",True)
    End If
End Sub

test2.jpg



so, when i try press ENTER after fill the itemcode TextBox, the program Error
 
Last edited:
Upvote 0

jamir

Member
where is the full error?
this code "mdlConn.CSR1=mdlConn.SQL1.ExecQuery("select * from myTabel where PartCode = '" & edtCdItem.Text & "'")" is running very well

the full error when program is running, when Press ENTER after type the SKU textbox
Error message in application when i add the sintaks "edtProdName.Text = Csr1.GetString("Name")" in Sub edtKode_EnterPressed
when i delete that syntax the application running very well

in this case, i want to display at NAME Textbox after i type the SKU textbox, with even EnterPressed

sorry my English so bad

thx Manfred for ur attention
 
Upvote 0

jamir

Member
typo : even -> event
in this case, i want to display at NAME Textbox after i type the SKU textbox, with event EnterPressed
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
In one place you refer to the cursor: mdlConn.CSR1 and in another place, you refer to it: CSR1 without a prefix. It should be without the prefix
 
Upvote 0

jamir

Member
edtProdName.Text = mdlconn.CSR1.GetString("ProdName")
I've tried that syntax before but the result is still error and then i try edtProdName.Text = CSR1.GetString("ProdName"), its the same error when the application running

btw thx Mahares, thank for ur share and coming... any solution again ?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
any solution again ?
Is there any chance you put a small project together to reproduce the problem. It does not seem too complicated to solve your problem. Someone, will probably get back to you. You have a better chance of getting a better answer.
Even if you do not get an answer you will get advice on: Using a full parameterized query, using resultset instead of cursor and closing the cursor when finished.
 
Upvote 0

jamir

Member
Is there any chance ysmall project together to reproduce the problem. It does not seem too complicated to solve your problem. Someone, will probably get back to you. You have a better chance of getting a better answer.
Even if you do not get aou put a n answer you will get advice on: Using a full parameterized query, using resultset instead of cursor and closing the cursor when finished.
ok i'll try again, thx so much Mahares....
 
Upvote 0

jamir

Member
In one place you refer to the cursor: mdlConn.CSR1 and in another place, you refer to it: CSR1 without a prefix. It should be without the prefix
thx Mahares, the problem is solved ??
fyi, im newbie at B4A, im VB6 user for desktop, and thank God i found B4A
 
Upvote 0
Top