Managed Dbf

Click here to edit subtitle

Blog

A journal on my database project named Spine-Tailed Swift Db it's a lightweight RDBMS library for .Net. It's a fast multi-user relational and thread safe database file management system, which are easy to use and understand, using some of the familiar commands of Visual FoxPro and other xBase compatible RDBMS. with an optional secured Client-Server base model.

 

 

view:  full / summary

Moving my blogs

Posted by nhylzcode on May 1, 2017 at 11:10 AM Comments comments (1)
Moving my blogs related to Managed Dbf to : https://manageddbf.blogspot.com/

Where and While Lambda condition for record deletion

Posted by nhylzcode on May 13, 2015 at 11:20 AM Comments comments (0)


Lambda expression, it's an anonymous function it can use to create delegates or expression tree, by using lambda condtions, we can write local functions that can be passed as parameters, let's see it in action for deleting a records with condition in Managed Dbf and it's equivalent Xbase/VFP/Clipper code.


// TASK : Delete all customers from USA country and state of New York or California.


|------------------------------------------------------------------------------------------------------------------------------------------------------


//--> SOLUTION 1:  (SLOW) : Single line of code
using  Where/For condition
//
var CUSTOMER = new STDB.Table();
CUSTOMER.File.Use( @"\\MyServer\Fileman\Customer.Dbf", TableShare.Shared, TableAccess.ReadWrite, TableMaxSize.MaxOf16G );
//                                                                       //For
CUSTOMER.Remover.DeleteAll (  true,   rec => cust.C("COUNTRY") == "USA"  &&  (  rec.C("STATE") == "NY" || rec.C("STATE") == "CA");



*--> XBase / VFP / Clipper  equivalent code
*
USE \\MyServer\Fileman\CUSTOMER.Dbf  SHARED ALIAS cust
GO TOP
DELETE ALL FOR cust.COUNTRY="USA" AND (  cust.STATE="NY" OR cust.STATE="CA" )


|------------------------------------------------------------------------------------------------------------------------------------------------------



//--> SOLUTION 2:  (  FAST ) Using index order by Country. and using For and  While condition overload.
//

var CUSTOMER = new STDB.Table();
CUSTOMER.File.Use( @"\\MyServer\Fileman\Customer.Dbf", TableShare.Shared, TableAccess.ReadWrite, TableMaxSize.MaxOf16G );
//
CUSTOMER.Indexer.SetIndexOrder("COUNTRY");
CUSTOMER.Searcher.Find("USA");
//
if (  CUSTOMER.Searcher.Found()  )
{   
      CUSTOMER.Remover.DeleteAll (  false,
                                                                   //For
                                                                       rec => ( rec.C("STATE") == "NY" || rec.C("STATE") == "CA" )  ,                                                              
                                                                   //While
                                                                       rec => ( rec.C("COUNTRY") == "USA" )   );
}



*-->  XBase / VFP / Clipper equivalent code
*
USE \\MyServer\Fileman\CUSTOMER.Dbf  SHARED ALIAS cust
SET ORDER TO COUNTRY
SEEK "USA"
IF FOUND()
     DELETE ALL FOR  ( cust.STATE="NY" OR cust.STATE="CA" ) WHILE cust.COUNTRY="USA"
ENDIF


|------------------------------------------------------------------------------------------------------------------------------------------------------

 

//--> SOLUTION 3: ( FASTEST )  Using index order by Country. and State. and While condition only
//

var CUSTOMER = new STDB.Table();

CUSTOMER.File.Use( @"\\MyServer\Fileman\Customer.Dbf", TableShare.Shared, TableAccess.ReadWrite, TableMaxSize.MaxOf16G );
CUSTOMER.Indexer.SetIndexOrder("COUNTRYSTATE");
//

CUSTOMER.Searcher.Find("USANY");
if
( CUSTOMER.Searcher.Found() )
{                                                                            //For    //While
     CUSTOMER.Remover.DeleteAll ( falsenull ,   rec => ( rec.C("COUNTRY") == "USA"  &&  rec.C("STATE") == "NY" )   );
}
//
CUSTOMER.Searcher.Find("USACA");
if (  CUSTOMER.Searcher.Found()  )
{                                                                             //For    //While
      CUSTOMER.Remover.DeleteAll ( falsenull ,   rec => ( rec.C("COUNTRY") == "USA" &&  rec.C("STATE") == "CA");
}

 

*--> xBase / VFP / Clipper code*
*
USE \\MyServer\Fileman\CUSTOMER.Dbf  SHARED ALIAS cust
SET ORDER TO CNTRYSTAT
*
SEEK "USANY"
IF FOUND()
    DELETE ALL WHILE cust.COUNTRY="USA" AND cust.STATE="NY"
ENDIF
*
SEEK "USACA"
IF FOUND()
    DELETE ALL WHILE cust.COUNTRY="USA" AND cust.STATE="CA"
ENDIF


 


Record locking

Posted by nhylzcode on April 24, 2015 at 2:15 PM Comments comments (0)


Visual Foxpro and Xbase has a RLOCK() and FLOCK() for it's record and file locking mechanism but only returns logical value .T. or .F., true if you successfully lock the file or a certain record, otherwise it returns false if failed. But there are times I need to know whether the record is lock by the application or it is locked by another process. What i've implemented in Managed Dbf; rather than just returning locical value true or false it returned an integet value ranging for 0 to 3.

0 - If current record is not lock.
1 - If locked by the application.
2 - if locked by other process local or other user from lan.
3 - If locking on invalid record ranged.


CUSTOMER.Navigator.GoTo( 100 );
//
If (  !  CUSTOMER.Locker.Lock() )
{

     int
mRet = CUSTOMER.Locker.IsLocked();
     //
     if ( mRet == 0 ) MessageBox.Show(" Record is free ");

     if ( mRet == 1 ) MessageBox.Show(" This record is lock by this process ");

     if ( mRet == 2 ) MessageBox.Show(" Ooopss other user or process lock this record ");

     if ( mRet == 3 ) MessageBox.Show(" Invalid record position ");

 }
else
{
     MessageBox.Show(" Record locking successfull ^_^y ");
}


But of course,  theres an overload to lock specific record number :)

// Lock record no 100
CUSTOMER.Locker.Lock( 100 );

Slow development harhar

Posted by nhylzcode on March 4, 2015 at 9:55 PM Comments comments (1)


Imma blame Blizzard for a while particularly StarCraft 2 for the slow development of this project :lol:


Any suitable alternative for Visual FoxPro? I can't find one!

Posted by nhylzcode on February 4, 2015 at 8:35 AM Comments comments (4)


I’ve been professionally developing business applications for more than 10 years mostly from small to medium-size enterprises, most of my applications are written in Visual FoxPro since Version 3.0 up until to the last version 9.0 SP2. So yeah, VFP is my bread and butter because it’s the best tool for getting things done specifically in developing enterprise desktop line of business applications.


To most VFP developers the following site and announcement from VFP team is not new https/msdn.microsoft.com/en-us/vfoxpro/bb308952 ( MS is not planning on releasing a VFP 10 ) it was really a sad news to all FoxPro fanatics like me. Nonetheless, rather than whining, I better start looking for an alternative tools for my future projects. I’m still looking up until 2020 till I stop developing application in VFP and as long as my clients couldn’t care less whatever development tools I use, as long as I continue to meet all of their requirements on time( VFP is a RAD tools, you know ^_^ ) I’m still going to use it.


Don’t get me wrong, I love keeping up with the new and latest technology and most of the time I usually hop on to the bandwagon on the latest technology and try to come up with something useful that I can use for my projects and It’s no brainer to just stick to one development tools, environment and programming languages particularly if you are a business software solution provider.


Yes, yes the technology is there. Only too many to choose from and most of the time it’s far too complicated for the end-users to get started and when you get the feeling that it’s a bit bloated, heavy weight, too much use of resources and experienced the install and uninstall hell the frustration of finding an alternative to VFP is getting worse. True, there are lots of available tools out there but it’s too fragmented, you need lots of add-on and other third party software to make simple line of business application out of the box.


Still, I can’t find a robust data centric development tools like what Visual FoxPro can offer, sure there’s Microsoft Access and LightSwitch :D but I rather create a full blown business application in Visual Studio and .Net framework. VFP is dead, XNA is dead, Silverlight is dead, MS Access and LightSwitch may die, but .Net framework probably last and evolved; not to mention that it can be ported to Mono with just a little effort.


dBASE was different from programs like BASIC, C, FORTRAN, and COBOL in that a lot of the dirty work had already been done. The data manipulation is done by dBASE instead of by the user, so the user can concentrate on what he is doing, rather than having to mess with the dirty details of opening, reading, and closing files, and managing space allocation”. -- Wayne Ratliff


As one of the great grandparents of dBase noted dBase(Clipper/xBASE/VFP) is a different beast in terms of data manipulation like in most general programming languages and C# is no exception to that. So, why not use the best of both worlds by using Visual Studio as the development tools and .Net framework as the language(C#/VB) and create a library that can bring the ease of use in data manipulation on VFP table without using VFP itself or it's runtime :)


Extending the life of DBF file format

Posted by nhylzcode on February 1, 2015 at 12:35 PM Comments comments (0)


Since this is my first post on  this blog, I already know what's running  into  your mind... You may say maybe I'm just reinventing the wheel. Why not design my own programming languages and write my own compilers for them? Or even better create my own operating system from scratch? :D because there are fricking hundreds if not thousands of available database projects out there in the wild which are ready to use and battle tested.


When you can’t find some information you are looking for at certain applications, or a good software library but lacking some option and features you need, why not create your own? If you have the luxury of time and you believe you can do it, why bother using a third-party software or the work of others.

Alright, aside from the pleasure I get writing codes, fulfilling my enthusiasm for extending the life of DBF file format and staying close to the xBase commands in data manipulation; has given me a great deal of enjoyment particularly in the learning process, these alreary are greenlight indications
that I should keep continuing what I’m doing.

But what’s the real story and my objectives? I’ll probably discuss it on my next blog…


Rss_feed