This is a migrated thread and some comments may be shown as answers.

insert new record to database please help

2 Answers 83 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Derya Altuntas
Top achievements
Rank 1
Derya Altuntas asked on 08 Nov 2009, 04:37 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Damyan Bogoev
Telerik team
answered on 09 Nov 2009, 03:33 PM
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.
0
Derya Altuntas
Top achievements
Rank 1
answered on 10 Nov 2009, 09:11 AM
Thanks a lot.It works now
Tags
Databases and Data Types
Asked by
Derya Altuntas
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Derya Altuntas
Top achievements
Rank 1
Share this question
or