strange do while behaviour

cirollo

Active Member
Licensed User
Longtime User
Hi I've the following code.....

B4X:
Conn1.BeginTransaction   
Command1.CommandText = "SELECT * FROM t_rilevazioni order by Id" 
Reader1.New1
Command1.ExecuteNonQuery
Reader1.Value = Command1.ExecuteReader
Do While Reader1.ReadNextRow = True
      rigafile=Reader1.GetValue(1)
      rigafile=StrRemove(rigafile,0,1)
      Msgbox(rigafile)
.......   
     'insert in remote sql table
.......
Loop

If i don't put the msgbox to show the value, the do while will take only the first record! why?
 

mjcoon

Well-Known Member
Licensed User
You'll have to check what you get in Reader1.ReadNextRow

I don't understand.

After all, the code as shown is the same as that in SQL.chm, viz:
Do While Reader.ReadNextRow = TRUE
ListBox1.Add(Reader.GetValue(0))
Loop

So assuming that the sample code in the Help has been shown to work (testing the result of Reader.ReadNextRow) why would cirollo's version not work?

Mike.
 

Basic4Life

Member
Licensed User
If it works when showing the messagebox, then there are probably only 1 or 2 options that might cause the error.
Timing and/or maybe window message queue processing
For timing add: Sleep(100) to your loop (or any longer timespan if needed)
(For message queue add: DoEvents)


So assuming that the sample code in the Help has been shown to work (testing the result of Reader.ReadNextRow) why would cirollo's version not work?
I've never done any relevant databse stuff with b4ppc, but as far as I understand, the sqllite stuff was implemented with the idea of the database being a local file, so if you connect to a server via a network things might work a little different
 
Last edited:

mjcoon

Well-Known Member
Licensed User
..., so if you connect to a server via a network things might work a little different

I've never wanted to, so haven't investigated, but I thought it was not possible!

It's only the comment that suggests this is happening (implying that the d/b being read is local?), so maybe removing the code behind the comment is another experiment?

Mike.
 

cirollo

Active Member
Licensed User
Longtime User
yes

I think it was only a time problem

putting sleep(1000) I give the prg a second to write to the db
I don't know that this will become not sufficient when I'm not so close to access point....

by the way, any suggestion for this problem?

I've an editbox in which I beam a barcode.
when the beam is ended, I launch a sql query to retrieve the name and description of the barcode item.

I cannot get the proper event! I'm trying with keypress but after beaming the code I've to put a space with keyboard to trigger that event!

any other idea???

let me know! regards,
 

Basic4Life

Member
Licensed User
I agree, Sleep() might not be the most reliable way to handle the issue. Maybe there's a better way, but I don't know enough about the inner workings of the sql libraries.

For your other problem:
I assume editbox = Textbox, in that case windows mobile does support the TextChanged event.
To use that you have to add the Door library to your program, then you can simply add this:
B4X:
AddObject("tbCode", "Object")
AddObject("tbCodeChanged","Event")
tbCode.New1(False)
tbCode.FromControl("[NameOfTextbox]")
tbCodeChanged.New1(tbCode.Value,"TextChanged")

'...

Sub tbCodeChanged_NewEvent

'text of textbox changed

End Sub

Alternatively you could probably use a Timer with a fairly low interval to check the Textbox.Text for change.
 

melamoud

Active Member
Licensed User
Longtime User
Not sure I completely understand the issue but if you can send me a standalone version I can help you.


Sent from my SCH-I545 using Tapatalk 2
 
Top