SQL Question

Discussion in 'Questions (Windows Mobile)' started by HARRY, May 13, 2007.

  1. HARRY

    HARRY Active Member Licensed User

    Hallo, SQLite experts!

    On the following statements :

    cmd.CommandText="UPDATE WPOILABEL_V1 SET PHOTO1 = Text1 ,PHOTO2 =Text2, PHOTO3 = Text3 WHERE ID=ActCampID;"
    cmd.ExecuteNonQuery

    I get the error message: SQLite error: No such column Text1

    WPOILABEL_V1 is really a table and PHOTO1 , PHOTO2 and PHOTO3 are really columns.

    What am i doing wrong?

    Harry
     
  2. Fontanus

    Fontanus Member Licensed User

    Hello Harry,

    test the following syntax:

    cmd.CommandText="UPDATE WPOILABEL_V1 SET PHOTO1 = '" &Text1& "' , PHOTO2 = '" &Text2& "', PHOTO3 = '" &Text3& "' WHERE ID= '" &ActCampID& "' "
    cmd.ExecuteNonQuery

    Bon Chance

    Fontanus
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Here is a reference to the SQLite documentation.
    What are Text1, Text2?
    Are these Textbox controls?
    If not then you should write:
    cmd.CommandText="UPDATE WPOILABEL_V1 SET PHOTO1 = 'Text1' ,PHOTO2 ='Text2', PHOTO3 = 'Text3' WHERE ID='ActCampID';"
     
  4. HARRY

    HARRY Active Member Licensed User

    Erel and Fontanus,

    Thanks for your help; it works now fine. I was confused where to use single and double quotes and &&.


    Harry
     
  5. HARRY

    HARRY Active Member Licensed User

    Hallo Fontanus,

    Back to an old problem.

    Can you explain me the need to use '"& ___&"' around each variable. Who is doing what with each pair of symbols? In the case I presented Text1, etc just are variables, local to the update sub

    I have tried your sample code and that of Erel. I got your solution working, that of Erel not. No error was raised , but the row just was not updated. I don't know why.

    So, I was happy with your solution until version 5 was released. Now none of both solutions work on the PDA. See also my new topic on this subject.

    Do you have an idea?

    Harry
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    The & signs are used to combine the variables with the strings.
    If you do: msgbox(cmd.CommandText) you shouldn't see any & sign.
    My solution didn't work cause I assumed that Text1/2/3 are not variables.
     
  7. HARRY

    HARRY Active Member Licensed User

    Erel,

    Thanks for the explanation of quotes, etc.. Looking at the sentence in a msgbox makes it clear.

    The problem is solved. I used the cmd.New1() and Reader.new1 repeatingly to refresh a table after update of the data base. SQLite desktop accepted this, SQlite device gave error messxages: two for each update.

    I now have added dispose and AddObject for both and now it works also on the device.

    These things are beyond your control I guess?

    Harry
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    It is always better to dispose the old object before creating a new one, making sure that all resources are freed.
     
Loading...