Wednesday, January 28, 2009

ASP.NET Applications with Delphi and Advantage Database Server

The white paper written by Cary Jensen I mentioned in a previous post about using the Advantage .NET Data Provider in Delphi for .NET and Delphi Prism is now available on the Advantage web site at the following link:

http://www.sybase.com/detail?id=1061908

Monday, January 26, 2009

Delphi Prism - Correction

In a previous post on Prism I said its dataset designer does not work with the Advantage data provider. That was not correct. Our legacy AdsDataAdapter designer does not work, but that designer has not been necessary since the Visual Studio 2002-2003 days.

With Visual Studio 2005 and newer, the ObjectDataSource object has removed the need to directly use an AdsDataAdapter.

Today I wrote some Prism tests that used the Advantage .NET Data Provider both directly and via drag and drop actions from the Server Explorer, and everything worked well. False alarm. Let me know if you have any problems with Prism, but so far it looks like a good solution for Delphi .NET developers. I really like the fact you can use our .NET data provider directly, without dbExpress or any other technologies in the way.

Saturday, January 24, 2009

Find Files Quickly

I’ve published a free command line utility that can be used to quickly find files on your hard drive. You can download it here.

I’ve always been frustrated with the file search capabilities in Windows. The search is slow and turning on the indexing service rarely increases performance. I know I’m not alone, as there are a handful of freeware and shareware utilities that provide enhanced file search capability. Even Google has tried to address this deficiency with Google Desktop. All of those solutions slowed my PC down or came with a ton of overhead and security concerns.

I wrote this utility sometime in 2004. I’ve been using it since then on all of my development and home PCs. Last week after performing steps to manually install it on some new laptops, I decided to create an install. Once the installation existed, I figured I might as well share it with everyone else.  :)

If you’ve used Linux before this is basically my own implementation of the Linux “locate” command.

The database locate uses will build in the background after installation, and be automatically updated each night via a scheduled task the installer creates. You can start using locate immediately after installation, but it will take a few minutes for the database to be populated. Searches during this time frame (immediately after installation) will not locate all files on disk.

The download is only 2 meg and installation takes seconds. Try it out and let me know what you think.

Friday, January 23, 2009

Using Advantage from Delphi Prism

I wrote my first Delphi Prism method today. Nothing crazy, just added a method to their existing ASP.NET example to verify our .NET Provider worked. It did. Our visual dataset designer does not currently work in Prism, as it has portions that make decisions based on the language, and it doesn't currently understand Oxygene. [correction: dataset creation works well. See my post correcting this error.]

It was kind of weird writing Pascal inside of Visual Studio. My hands kept trying to use Delphi keyboard shortcuts to start and control the debugger.  :)

In a few days we are going to release a white paper written by Cary Jensen about building ASP.NET applications using Delphi for .NET and Advantage. It covers the concept and benefits of using a "hand written" data layer as opposed to littering your pages with design-time components. The concept applies to Delphi Prism as well as Delphi for .NET.

I'm including my test method below as a starting point if you feel like experimenting with Prism and Advantage.

To use the code:

  • Open the Prism Simple ASP.NET example application.
  • Add a project reference to Advantage.Data.Provider.dll (right click the project in the Solution Explorer, Add Reference...)
  • Then just copy this text over all of the text in the Prism example index.aspx.pas
namespace;
 
interface
 
uses
  System,
  System.Data,
  System.Configuration,
  System.Web,
  System.Web.Security,
  System.Web.UI,
  System.Web.UI.WebControls,
  System.Web.UI.WebControls.WebParts,
  System.Web.UI.HtmlControls,
  Advantage.Data.Provider;
 
type
  IndexPage = public partial class(System.Web.UI.Page)
  protected
    method btnRefresh_Click(sender: System.Object; e: System.EventArgs);
    method QueryAdvantage;
  end;
 
implementation
 
method IndexPage.QueryAdvantage;
var
   Conn : AdsConnection;
   Cmd  : AdsCommand;
   Rdr  : AdsDataReader;
begin
   Conn := new AdsConnection;
   Conn.ConnectionString := 'data source=c:\;ServerType=local;TableType=ADT';
   
   try
      Conn.Open;   
      Cmd := Conn.CreateCommand;
      
      // Create temp table
      Cmd.CommandText := 'try drop table #quicktest;' +
                         'catch all end try;' +
                         'create table #quicktest( id integer, name cichar(20) );' +
                         'insert into #quicktest values( 1, ''Windham'' );' +
                         'insert into #quicktest values( 2, ''Reed'' )';
      Cmd.ExecuteNonQuery;         
      
      // Quick Query
      Cmd.CommandText := 'select * from #quicktest';
      Rdr := Cmd.ExecuteReader;
            
      // Spit out some data
      while ( Rdr.Read ) do
      begin
         Response.Write( 'ID: ' + Rdr[0].ToString + ' Name: ' + Rdr[1].ToString + '<br/>' );
      end;   
                
   finally
      Conn.Close;     
      Conn.Dispose;
   end;
   
end;
 
method IndexPage.btnRefresh_Click(sender: System.Object; e: System.EventArgs);
begin
 
  QueryAdvantage;
 
  try
    var lValue: Double := Double.Parse(edInput.Text, System.Globalization.NumberFormatInfo.InvariantInfo);
    
    edCtoC.Text := (lValue).ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
    edFtoC.Text := ((lValue - 32) / 1.8).ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
    edKtoC.Text := (lValue - 273.15).ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
    edCtoF.Text := (lValue * 1.8 + 32).ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
    edFtoF.Text := (lValue).ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
    edKtoF.Text := (lValue * 1.8 - 459.67).ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
    edCtoK.Text := (lValue + 273.15).ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
    edFtoK.Text := ((lValue + 459.67) / 1.8).ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
    edKtoK.Text := (lValue).ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
    edMItoKM.Text := (lValue / 0.621371192).ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
    edKMtoMI.Text := (lValue * 0.621371192).ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
  except
    edCtoC.Text := 'Invalid number';
    edFtoC.Text := 'Invalid number';
    edKtoC.Text := 'Invalid number';
    edCtoF.Text := 'Invalid number';
    edFtoF.Text := 'Invalid number';
    edKtoF.Text := 'Invalid number';
    edCtoK.Text := 'Invalid number';
    edFtoK.Text := 'Invalid number';
    edKtoK.Text := 'Invalid number';
    edMItoKM.Text := 'Invalid number';;
    edKMtoMI.Text := 'Invalid number';
    exit;
  end;
end;
 
end.

Tuesday, January 20, 2009

Delicious Bookmark Search via Chrome

I had been avoiding Google Chrome for a while due to my addiction to easily searching my delicious bookmarks. This post by Fernando back in September 08 has a solution that has me using Chrome again.

While this search is nice and will do the job for now, I still like the Firefox delicious plugin because it automatically sorts my bookmarks by popularity (how often I click them).

Adding the Advantage Developer's Zone search to Chrome as described by Chris and Edgar makes using Chrome even more fun. Especially since Edgar updated the DevZone search this week to search the online help files as well. Now with a single search you can quickly get search results from the following locations: help files, knowledge base, release notes, tech tips, screencasts and newsgroups.

Wednesday, January 7, 2009

Friday, January 2, 2009

Great Utility for Mounting ISO Images

There are a variety of methods to directly mount an ISO image so you don't have to burn a CD or DVD in order to view its contents.

Methods I've used in the past involved installing weird drivers and at least 4 or 5 cumbersome steps.

This week I used a very cool utility called Virtual CloneDrive from SlySoft. Just install it. Then right-click on any ISO file and select "open".

Kudos as usual to the How To Geek for pointing me to this utility.