SubSonic Forums
All Your Database Are Belong To Us

SQL Replace function

Latest post 07-07-2008 12:29 PM by Philmee95. 9 replies.
  • 06-23-2008 7:16 AM

    • mitica
    • Top 500 Contributor
    • Joined on 05-28-2008
    • The Netherlands
    • Posts 7

    SQL Replace function

     How do you write this statement with Subsonic:

    Update 	authors
    Set	city = replace(city, 'Salt', 'Olympic')

     

    Filed under:
  • 06-23-2008 10:15 AM In reply to

    Re: SQL Replace function

     

    Not all qquerys can be made using the builtin in object builders.  Sometimes you just have to execute some SQL.

    Dim querysql As String = "Update authorsSet city = replace(city, ''Salt'', ''Olympic'')"
            Dim queryc As New SubSonic.QueryCommand(querysql, DataService.Provider.Name)

    DataService.ExecuteQuery(queryc)

     

  • 06-23-2008 12:56 PM In reply to

    • mitica
    • Top 500 Contributor
    • Joined on 05-28-2008
    • The Netherlands
    • Posts 7

    Re: SQL Replace function

     

    Thank you.

     

  • 06-25-2008 8:03 PM In reply to

    Re: SQL Replace function

    // run a delete query instead of itterating over payments collection
    SubSonic.Query qDelete = new SubSonic.Query( GenClass.Schema);
    qDelete.QueryType = SubSonic.QueryType.Delete;
    // add keys to delete accross
    qDelete.WHERE( GenClass.Columns.aField, "aField value");
    qDelete.Execute();

    substitute your classes where needed. This is what I use to update and delete using subsonic.

    I believe qDelete.AddUpdateSetting( field, value) will update your columns on the found set.

    Found this in the forums awhile back. Your query type would be Update of course.  GenClass is a Subsonic Generated Class, and istead of typing out the field  names, I used my Subsonic object, so if I screw up my table schema names, I will get a compiler error and I keep the DB layer almost hidden from the presentation...mixed with the subsonic generated layer anyways.

  • 06-25-2008 11:38 PM In reply to

    Re: SQL Replace function

     NM, I thought you were just updating a value and not calling a function.

  • 06-28-2008 6:00 AM In reply to

    • mitica
    • Top 500 Contributor
    • Joined on 05-28-2008
    • The Netherlands
    • Posts 7

    Re: SQL Replace function

     Philmee95, it doesn't matter, thank you for trying to help me out.

     

  • 07-03-2008 5:02 AM In reply to

    Re: SQL Replace function

    3x!My MSN:yuyejian@hotmail.com  Website:www.ucfar.cn

     

  • 07-03-2008 11:12 AM In reply to

    Re: SQL Replace function

     

    ExecuteReader, ExecuteDataset, or fill your ClassCollection for the news table that you generated from subsonic (NewsCollection.load( qc);

  • 07-04-2008 4:49 AM In reply to

    Re: SQL Replace function

     new YourProviderName.AuthorsControlers(),update('city','Salt','Olympic');

    Just easy to do it...
    
    
  • 07-07-2008 12:29 PM In reply to

    Re: SQL Replace function

     Sorry, posted this on wrong thread

Page 1 of 1 (10 items) | RSS