Datareader crashes on quotes

Dataverde

Member
Licensed User
Longtime User
EDIT:
Problem solved... my fault.
------------------------------------------

Hi there,

it seems like the datareader crashes when it reads text with quotes from a sqlite database.


B4X:
Sub find_inhouse_PLU(art_nr)
   cmd.CommandText = "SELECT BEZEICHNUNG,QUALITAET,GROESSE,VK_PREIS,ARTIKEL_NR FROM ARTIKEL WHERE ARTIKEL_NR = " &q& art_nr &q
   dta_rdr.Value = cmd.ExecuteReader
   tmp_name = dta_rdr.GetValue(0)
   tmp_quali = dta_rdr.GetValue(1)
   tmp_preis = dta_rdr.GetValue(2)
   tmp_groesse = dta_rdr.GetValue(3)
   tmp_artnr = dta_rdr.GetValue(4)
   dta_rdr.Close
   fill_F3TBs(tmp_name,tmp_quali,tmp_preis,tmp_groesse,tmp_artnr) 
End Sub

I tried to build a workaround with this:

B4X:
Sub find_inhouse_PLU(art_nr)
....
   dta_rdr.Value = kill_quotes(cmd.ExecuteReader)
....
End Sub

Sub kill_quotes(arr)
   For i = 0 To ArrayLen(arr) 
      arr(i) = StrReplace(arr(i),q,"") 'q is Chr(34)
   Next
   Return arr
End Sub

But now its telling me that im´ using an undeclared array...
What am i missing here?
Is cmd.ExecuteReader even in Array Format?

Greetings,
Lennart
 
Last edited:

klaus

Expert
Licensed User
Longtime User
In your calling routine
B4X:
Sub kill_quotes(arr)
    For i = 0 To ArrayLen(arr) 
        arr(i) = StrReplace(arr(i),q,"") 'q is Chr(34)
    Next
    Return arr
End Sub
you use the arr variable which in this case is considered as a single variable and not an array.
you cannot pass an array to a subroutine.

You should declare your arr array in Globals and change the routine like this.
B4X:
Sub kill_quotes
    For i = 0 To ArrayLen(arr) 
        arr(i) = StrReplace(arr(i),q,"") 'q is Chr(34)
    Next
End Sub

Best regards.
 

Dataverde

Member
Licensed User
Longtime User
Thanks for the fast reply.

The error accured because of another sqlite command witch was using tmp_name.
Because tmp_name included some quotes the sql command crashed.

B4X:
name = tmp_name
cmd.CommandText = "SELECT BEZEICHNUNG,QUALITAET,VK_PREIS,GROESSE,ARTIKEL_NR FROM ARTIKEL WHERE Bezeichnung LIKE " &q&"%" & name & "%" &q& "ORDER BY BEZEICHNUNG, QUALITAET"

So it was my fault and the executereader is fine with quotes.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…