insert new record to database please help

3 posts, 1 answers
  1. Derya Altuntas
    Derya Altuntas avatar
    5 posts
    Member since:
    Nov 2009

    Posted 08 Nov 2009 Link to this post

    I want to add new entity to database  using telerik
    At starting,I tried to generate Table Class and set members using set procedure.
    this works  when no inner  relationship betwwen tables
    now ı want to insert a new record to table with inner relationship.I have tried using native sql using sample in this page.But this doesn't work.This is my code.

    if(!m_scope.Transaction.IsActive)
                {
                    m_scope.Transaction.Begin();
                }

                //UNIQUEIDENTIFIER

                try
                {
                    for (int i = 0; i < m_loadedAirToAirMunition.Count; i++)
                    {
                        IQuery query = m_scope.GetSqlQuery("sp_ins_Pltfrm_Conf ?,?,?,?",

                                                null,

                                        "UNIQUEIDENTIFIER object_ID, UNIQUEIDENTIFIER platform_ID, INTEGER configuration_item_type, INTEGER quantity");



                        IQueryResult a = query.Execute(new object[] {((WeaponMissileAirToAir)m_loadedAirToAirWeaponMissile[i]).Id, selectedAirPlatform.Id, Constants.CHANGE_CONFIGURATION_MUNITION_AIR_AIR, ((MunitionPresentation)m_loadedAirToAirMunition[i]).getMunitionQuantity() });
                        
                    }
                    m_scope.Transaction.Commit();
                }
                catch (Exception e)
                {
                    string a = e.Message;
                }
  2. Answer
    Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 09 Nov 2009 Link to this post

    Hi Derya Altuntas,

    You will have to invoke the execution of the query. It is not executed until the result is used somewhere in the code. To achieve this you can use the following statement:
    int count = a.Count;

    It should take place after the query definition:
    IQueryResult a = query.Execute(new object[] {((WeaponMissileAirToAir)m_loadedAirToAirWeaponMissile[i]).Id, selectedAirPlatform.Id, Constants.CHANGE_CONFIGURATION_MUNITION_AIR_AIR, ((MunitionPresentation)m_loadedAirToAirMunition[i]).getMunitionQuantity() });
    Hope that helps.

    Sincerely yours,
    Damyan Bogoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Derya Altuntas
    Derya Altuntas avatar
    5 posts
    Member since:
    Nov 2009

    Posted 10 Nov 2009 Link to this post

    Thanks a lot.It works now
Back to Top