Monday, August 2, 2010

FAQs – July 2010

Returning Custom Errors from a .NET AEP

When writing Stored Procedures in an external library custom error messages can be returned by adding the messages to the __error table. This is similar to the RAISE command in SQL scripts. Here is an example from the .NET AEP template

catch (Exception e)
{
  IDbCommand oErrCommand = oStateInfo.DataConn.CreateCommand();
  // Handle any exceptions here. Errors can be returned by placing a
  // row into the __error table.
  oErrCommand.CommandText = "INSERT INTO __error VALUES( 1, '" + e.Message + "' )";
  oErrCommand.ExecuteNonQuery();
}

In version 10 the __error table is not being populated correctly when the stored procedure has input parameters defined. This will be fixed in a future release of Advantage. If you need to return custom error messages consider using an SQL script for the stored procedure or returning the error message in an output parameter.

.NET Data Provider Versions

There is a .NET Data Provider for both the 1.0 and 2.0 .NET Framework. The Entity Framework Provider only works with the 3.5 and newer .NET Framework. There are a few differences between the 1.0 and 2.0 versions of the .NET Data provider. You can tell them apart by their version numbers 9.10.1.x and 9.10.2.x respectively.

If you are using the AdsConnectionStringBuilder you must use the ADO.NET 2.0 version of the .NET Data provider. The AdsConnectionStringBuilder is not available in the 1.0 version of the Data Provider.

The Advantage.Data.Provider.dll is included in three different folders under C:\Program Files\Advantage X.X\ado.net, by default. There is a 1.0 directory, a 2.0 directory and a redistribute directory. The redistribute directory contains the ADO.NET 1.0 version of the provider.

Refreshing of the AdsServer.ini

Generally changes to the AdsServer.ini file will be applied by the server quickly. Both the Windows and Linux versions of the server check the file regularly for changes. However, if the file does not exist when the Windows server first starts up it will not check for the file until it is restarted.

No comments: