Thursday, February 21, 2008

Getting Started With Visual FoxPro and Advantage

I've put together a short (11 minute) screencast for FoxPro users who are curious about Advantage, but don't know where to start.

It is always easier (at least for myself) to watch someone else do something than it is to search through mounds of documentation that is unfortunately often written for readers who already have some background with the product.

Let me know if you have other questions or topics you would like to see in a future screencast.

View the FoxPro Screencast Now

Download the screencast (26MB, open fox1.html after unzipping)

For more information on Advantage you can visit Getting Started for Visual FoxPro Developers, e-mail us at, or attend an Advantage Training.

Wednesday, February 13, 2008

Direct Table Access in ADO.NET

Dealing with the disconnected recordset paradigm in ADO.NET can often present hurdles, especially if you come from an ISAM/navigational background and are used to dealing with direct table opens.

The Advantage .NET Data Provider provides a class that is meant for all of you ISAM lovers out there (we know you're out there), the AdsExtendedReader class.

While this class is a descendant of the AdsDataReader class, its functionality is not limited to reading data. The class can be used to set scopes, perform index seeks, lock specific records, update records, etc. It is basically a class that exposes much of the Advantage ISAM functionality to ADO.NET users, and is part of what makes Advantage unique.

One powerful use of this class is to provide lookup combo boxes that do not require the overhead of multiple SQL statement executions. An AdsExtendedReader can be used to quickly scope table contents based on the current contents of the combo box. Let's take a look at some example code that does just that.

I have built an example application with two controls; a button and a combo box. The button is used to open a table and set an active index:
    private void button1_Click( object sender, EventArgs e )
      // connect
      // open the table, adsCommand1 is just a "SELECT *" statement
      oExtendedReader = adsCommand1.ExecuteExtendedReader();
      // Set the active index
      oExtendedReader.ActiveIndex = "lastname";

The combo box has one event defined; the TextUpdate event. This event fires whenever the text in the combo box has been modified. As the user types, it sets a scope (sometimes also called a range) on the table and fills the drop down with values from the table that pass the scope conditions.

Setting a scope results in a simple seek operation on the table. No files are closed and reopened. No SQL engine is involved in re-executing a query. An index seek is the fastest way for Advantage to locate a record.
    private void comboBox1_TextUpdate( object sender, EventArgs e )
      Object[] oKeys = new Object[1] {comboBox1.Text};
      int i = 5;
      int iCursor;
      // Here's the fun part, a connected dataset scope inside .net
      // This table could have a million records, but they are not all read
      // into an in-memory table on the client. We are using an index on
      // the server for a very fast and efficient scope.
      oExtendedReader.SetRange( oKeys, oKeys );
      // Save current cursor position
      iCursor = comboBox1.SelectionStart;
      // Clear the combobox list and add a few items from the reader's current
      // position.
      while ( ( !oExtendedReader.EOF ) && ( i > 0 ) )
        comboBox1.Items.Add( oExtendedReader["lastname"].ToString() );
      // If there are some matches, show the drop down
      if ( comboBox1.Items.Count > 0 )  
        comboBox1.DroppedDown = true;  
      // Set the cursor back to where it was
      comboBox1.SelectionStart = iCursor;             

The video below shows the example application in action.

What are you using the AdsExtendedReader for? Any functionality you would like to see added?

Thursday, February 7, 2008

Delphi: Did You Know #1

Did you know you can bring up the ARC table designer directly in the Delphi IDE?

No need to open ARC if you want to add fields, modify indexes, etc. Just right-click on the TAdsTable component and select "ALTER/Restructure Table...".

You will get the exact same table designer that is in ARC, only without the trouble of disrupting your workflow and starting ARC, connecting to the database and opening the table properties.

Make your structure change, close the dialog, and get back to work.

Sunday, February 3, 2008

ARC: Did You Know #2

Did you know you can finally drag and drop files onto an existing ARC instance and it will open them?

The main reason I am posting this is for those of you who tried years ago, learned ARC could not open the files, and gave up trying. The drop support was fixed in a recent update to ARC 8.1

You can now drag a table or dictionary instance from Windows Explorer and drop in on ARC and it will be opened.

Added Bonus: A sidebar of sorts on reporting bugs/enhancement requests

I'm going to attempt a preliminary strike against the "This is trivial. Why didn't you do this earlier" comments: We love the keyboard. By "we" I mean the Advantage R&D team. We are not big mouse users, hence the reason you have always been able to open a table or dictionary from the command line. This doesn't mean ARC shouldn't be able to open a table by dragging it, it just means we don't use ARC that way, so we didn't notice the lack of support.

I'm sure many of you have tried this in the past, noticed it didn't work, mumbled something under your breath, and continued on. I think this is very common in the software industry and I know I do it all the time. I don't have time to interrupt my work flow, find some way to submit a request to the vendor, then post what feels like a "trivial" problem that I don't think they will take seriously. (I'll write an entire post in the future about how important those "trivial" things that drive you crazy truly are.)

I'm hoping in the future we can add a simple dialog to the help menu in ARC that lets users submit a bug or feature request. You wouldn't have to search a web site or post to our newsgroups. We wouldn't require any information other than your request and your e-mail address if you feel like providing it so we can clarify your request if necessary.

My favorite third party website is provided by Developer Express. I love their support center. Before submitting a question or bug report, I am forced to do a quick search on existing issues. If I don't find a relevant post, I am allowed to post my question. I can keep my question private, or by default have then entire conversation with their support staff public. This automatically results in a superior knowledge base for other users to search. This is a bit more ambitious than what I am currently proposing, but I'd like to see us get to this sort of system at some point.

Anyway, hope you enjoyed this "short" Did You Know...

My FoxShow Interview

A recent interview I did with Andrew MacNeill has been posted on his FoxShow podcast #49. Andrew and others in the FoxPro community have been fairly interested in Advantage and our upcoming Visual FoxPro support. Thanks again to Andrew for the interview. It's much easier to explain a product in person like this as opposed to a few marketing bullets in a print ad.