How to control error when using Activex Automation.

icafferata
Member Posts: 5
Good Mornig:
I'll appreciate so much if someone can help me where to find documentation and examples about the use od ActiveX Data Objects in Navision. Now i am using version 2.7.
With the next code I can make modifications to record in DBASE IV, but, if the record already exists the application stop execution.
SQL_Insert:='INSERT INTO '+rec_Config_Cont."Tabla Artículos";
SQL_Insert+='(AL_CODEART,AL_DESCRIP,TARIFA_1,COSTEUNI,AL_CODPRO,AL_MINIMA,TARIFA_2,TIPO_IVA,AL_PEDIDO,AL_FAMI_AR,';
SQL_Insert+='SUBFAMILIA,AL_COD_FAB) ';
SQL_Insert+='VALUES('''+rec_producto."No."+''','''+CONVERTSTR(rec_producto.Description,'''',' ')+''',';
SQL_Insert+=pvp+',';
SQL_Insert+=CONVERTSTR(FORMAT(rec_producto."Unit Cost"),',','.');
SQL_Insert+=','''+rec_producto."Vendor No."+''',';
SQL_Insert+=FORMAT(rec_producto."Reorder Point")+',';
SQL_Insert+=pvr+',';
SQL_Insert+=''+rec_Grupo_Reg_IVA_Prod.IVA_DbaseIV+','+FORMAT(rec_producto."Cant.Ped.Minimo Tienda")+',';
SQL_Insert+='''' + rec_producto."Item Category code"+''','''+rec_producto."Product Group Code"+''',';
SQL_Insert+='''' + rec_producto."No." + ''')';
//Ejecución de la sentancia SQL
DBFRecord.Open(SQL_Insert,DBFConnect,2,3);
This code works but if the record exists it gives an error and stop the process, then, i need to capture the error and control it.
Many thanks in advance
I'll appreciate so much if someone can help me where to find documentation and examples about the use od ActiveX Data Objects in Navision. Now i am using version 2.7.
With the next code I can make modifications to record in DBASE IV, but, if the record already exists the application stop execution.
SQL_Insert:='INSERT INTO '+rec_Config_Cont."Tabla Artículos";
SQL_Insert+='(AL_CODEART,AL_DESCRIP,TARIFA_1,COSTEUNI,AL_CODPRO,AL_MINIMA,TARIFA_2,TIPO_IVA,AL_PEDIDO,AL_FAMI_AR,';
SQL_Insert+='SUBFAMILIA,AL_COD_FAB) ';
SQL_Insert+='VALUES('''+rec_producto."No."+''','''+CONVERTSTR(rec_producto.Description,'''',' ')+''',';
SQL_Insert+=pvp+',';
SQL_Insert+=CONVERTSTR(FORMAT(rec_producto."Unit Cost"),',','.');
SQL_Insert+=','''+rec_producto."Vendor No."+''',';
SQL_Insert+=FORMAT(rec_producto."Reorder Point")+',';
SQL_Insert+=pvr+',';
SQL_Insert+=''+rec_Grupo_Reg_IVA_Prod.IVA_DbaseIV+','+FORMAT(rec_producto."Cant.Ped.Minimo Tienda")+',';
SQL_Insert+='''' + rec_producto."Item Category code"+''','''+rec_producto."Product Group Code"+''',';
SQL_Insert+='''' + rec_producto."No." + ''')';
//Ejecución de la sentancia SQL
DBFRecord.Open(SQL_Insert,DBFConnect,2,3);
This code works but if the record exists it gives an error and stop the process, then, i need to capture the error and control it.
Many thanks in advance
Italo Cafferata
0
Comments
-
You should better do something like:
gblAdoCommand.CommandType := 1;
gblAdoCommand.ActiveConnection(gblCadenaConexion);
cadenaSql := STRSUBSTNO('INSERT INTO %1 (%2) VALUES (%3)', tabla, campos, valores);
gblAdoCommand.CommandText := cadenaSql;
gblAdoCommand.Execute(numRegistros);
EXIT(numRegistros);
If numRegistros=0 Then some error occurs.
Another way is writing a wrapper that allows you to properly control any errors.
-- Alejandro --0 -
Maybe you should first check if the record you are trying to insert exists through a select statement ?0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions