Hi Steeve,
What you are doing is correct. I don't have an EmployeeTable so I have
used the CustTable. Create a job and try this.
Here is my code:
CustTable custTable;
;
try {
custTable.initValue();
custTable.AccountNum = "0";
custTable.Name = "Tom Hoebers";
custTable.Address = "THO";
custTable.insert();
print "OK";
pause;
}
catch (exception::Error) {
print "the error is never catched...";
pause;
}
AccountNum is a unique index so the second run will cause a SQL
violation, which in turn will result in the Axapta kernel throwing an
exception and falling into my catch block.
This doesn't off course disable the infolog. If you turn it off always
remember to set it back to the original level before exiting.
I assume there is more to your code if it isn't working.
Regards,
--
Luis Mour�o
[EMAIL PROTECTED]
--- In [EMAIL PROTECTED], "RHODPR"
<[EMAIL PROTECTED]> wrote:
>
>
> Yes I can, I know that is an option. But is there any way to catch
> such an exception? Maybe there will be other exceptions that are
> thrown by SQL Server, I just want to know if it's possible to catch
> them...
>
> --- In [EMAIL PROTECTED], "Steeve Gilbert"
> <[EMAIL PROTECTED]> wrote:
> >
> > Can't you just do a select statement to check if the record
> already exists?
> >
> > Steeve...
> >
> >
> > -----Message d'origine-----
> > De : RHODPR [mailto:[EMAIL PROTECTED]
> > Envoy� : 27 octobre 2004 05:54
> > � : [EMAIL PROTECTED]
> > Objet : [development-axapta] error catching when inserting in
> SQLServer
> >
> >
> >
> >
> > Hi all,
> > I want to insert a new record in the EmployeeTable in Axapta (SQL
> > Server). If there is already an employee in it with the same
> > EmplId, it (SQL Server I guess) returns an error. How can I catch
> > this error? The code below doesn't work : the error is directly
> > shown on the screen, and is never catched... I already tried all
> of
> > the exception-types, yet none works...
> >
> > try {
> > employeeTable.InitValue();
> > employeeTable.Name = "Tom Hoebers";
> > employeeTable.EmplId = "THO";
> > employeeTable.insert();
> > }
> > catch (exception::Error) {
> > print "the error is never catched...";
> > pause;
> > }
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/development-axapta/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

