Datareader crashes on quotes

Discussion in 'Questions (Windows Mobile)' started by Dataverde, Mar 9, 2009.

  1. Dataverde

    Dataverde Member Licensed User

    EDIT:
    Problem solved... my fault.
    ------------------------------------------

    Hi there,

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


    Code:
    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:

    Code:
    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: Mar 9, 2009
  2. klaus

    klaus Expert Licensed User

    In your calling routine
    Code:
    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.
    Code:
    Sub kill_quotes
        
    For i = 0 To ArrayLen(arr) 
            arr(i) = StrReplace(arr(i),q,
    ""'q is Chr(34)
        Next
    End Sub
    Best regards.
     
  3. Dataverde

    Dataverde Member Licensed 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.

    Code:
    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.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice