Wednesday, September 2, 2009

FAQs – August 2009

Signaling an Event

It has been about a year since I wrote a demo and an article on using Advantage Notifications. You can read the technical overview in this tech tip. There is a Visual Studio example application available on Code Central.

One potential pitfall when using events is how the data path is defined. Events are registered with the connection path and name therefore all clients that wish to listen for a particular event need to be using the same connection path. For best results I recommend using a UNC path with the IP address, Port number and share/alias name (i.e. \\192.168.0.10:6262\MyData ). Using the same connection path and event name from all clients will ensure that all clients are notified when the event is triggered.

Using the Advantage Delphi Components on Vista

By default the Advantage Delphi Components are installed to the Program Files directory (C:\Program Files\Advantage 9.10\TDataSet). Normal users do not have rights to create new files in the Program Files directory. Therefore when you compile your application you may receive a F2039 compiler error in Delphi.

This error can be avoided by turning off the Vista User Access Control (UAC), which is not recommended. You can run Delphi as an Administrator which has the proper rights to create files under the Program Files directory or you can change the output path for your project.

You can get detailed instructions about these options from this knowledge base item. Windows 7 has the same security restrictions as Vista.

Passing Data with Temp Tables

Temporary tables can be created with SQL statements by preceding the table name with a pound ( # ) symbol. These tables are only available on the connection and are destroyed when the connection is closed. These tables can be very useful for passing information to stored procedures and views.

Stored procedures accept input parameters through the __input table. However, this table can only contain a single row so you must call the stored procedure over and over if you need to run it multiple times with different parameters. By using a temporary table you can populate the temporary table with multiple records. The stored procedure could then loop through the table processing multiple inputs with a single call.

This technique can also be used to pass a parameter to a view. This tech-tip demonstrates the technique.

Using LINQ to SQL with Prism

Delphi Prism allows object Pascal code, called oxygene, to be compiled by Visual Studio. It comes with the Visual Studio 2008 shell and can be used as a stand alone product. It contains many of the features of Visual Studio including the use of Language Integrated Query (LINQ).

Cary Jensen wrote two blog posts about using LINQ to SQL on his blog. Part I introduces you to the LINQ syntax and part II demonstrates using LINQ to SQL in Prism.

No comments: