×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    48

    Update SQL statement doesn't work

    Hi All,

    I`m trying to update a table in my database using the following code


    _LIT(KSQLUpdate," UPDATE ConfigSettings SET Source=%S, Target=%S,
    Audi=%d" );
    TBuf< 100> * tmpText=new(ELeave) TBuf< 100> ();
    CleanupStack::PushL(tmpText);
    tmpText-> Format(KSQLUpdate,& (iModel-> Source()),& (iModel->
    Target()),iModel-> Audi);
    iEngineDB.Execute(*tmpText);
    CleanupStack::PopAndDestroy(tmpText);

    Whenever I run this code I get an error saying Bad request.
    I have gone through several other posts and all of them have used a SELECT
    SQL query within a view in order
    to update data within the table.

    Is the usage of Update SQL Statement wrong here or do I have to use the
    Update statement differently?
    Is the updation of table only allowed through SELECT SQL query? Can`t I use
    the update statement directly similar
    to the INSERT statement?

    Any help in this regard will be greatly appreciated.

    Thanks & regards,
    Asheesh

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    48
    Hi,
    I was able to solve my problem.
    Basically the problem was with the missing single quotes for
    the varchar columns and also an unwanted parentheses.
    I'm sorry to have disturbed for this silly problem.

    Regards,
    Asheesh

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    7

    Re: Update SQL statement doesn't work

    Quote Originally Posted by asheeshv View Post
    Hi All,

    I`m trying to update a table in my database using the following code


    _LIT(KSQLUpdate," UPDATE ConfigSettings SET Source=%S, Target=%S,
    Audi=%d" );
    TBuf< 100> * tmpText=new(ELeave) TBuf< 100> ();
    CleanupStack::PushL(tmpText);
    tmpText-> Format(KSQLUpdate,& (iModel-> Source()),& (iModel->
    Target()),iModel-> Audi);
    iEngineDB.Execute(*tmpText);
    CleanupStack::PopAndDestroy(tmpText);

    Whenever I run this code I get an error saying Bad request.
    I have gone through several other posts and all of them have used a SELECT
    SQL query within a view in order
    to update data within the table.

    Is the usage of Update SQL Statement wrong here or do I have to use the
    Update statement differently?
    Is the updation of table only allowed through SELECT SQL query? Can`t I use
    the update statement directly similar
    to the INSERT statement?

    Any help in this regard will be greatly appreciated.

    Thanks & regards,
    Asheesh
    The usage of Update SQL Statement is wrong

  4. #4
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Update SQL statement doesn't work

    Quote Originally Posted by hello_j2me View Post
    The usage of Update SQL Statement is wrong
    Hi hello_j2me, might already noticed that the original post is more then 3 years old.

  5. #5
    Registered User
    Join Date
    Mar 2006
    Location
    India
    Posts
    503

    Re: Update SQL statement doesn't work

    TBuf<200> query;
    HBufC* Id= NULL;

    // assign according to uId has some value

    RDbStoreDatabase iDatabase;

    //open the database //

    //update query

    query.Format(_L("Update %S SET LastShownAdId = '%S'"), &KTableDynamicAd,&Id);
    iDatabase.Execute(query);
    Regards
    Kamal :)
    ------------------
    You never expect what expects you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×