Welcome to Foxite.COM Community Weblog Sign in | Join | Help

Anil Sharma

This is my Blog For VFP and VB.NET just sharing my programming experience with all u. U all are welcome here! :)

<January 2009>
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

Post Categories

Navigation

Syndication

How to Select Accounts/item in Forms with Sql/MySql Backend
When i started developing software with VFP/SQL  my initial problem was the select the accounts or items in my data entry forms. Initially i started making a cursor in my form load to use the selection in form. But by doing this my cursor was blind it cant see the addition updatation to the backend database. I started making a fresh cursor everytime when i need list. But that was also causing problem becaz. of burden on sever and user have to wait.. and this wait increase if your base table have more records. Then i decide to make the form which gives me always fresh records from table and that will also not choking my network.

The all Form is just based on single query string. I have uploaded the form u can download from here and u just need this syntax to run the form.

First Parameter : Query to Send Fields  and like condition to match on which field
2nd  Parameter : Your Application's Sql Connection String ID.
3rd  Parameter :  Find on which Field pass that field name
4th  Parameter :  Give the Fields to Display in List 
5th  Parameter :  Give the Field Name For Return Value Most of time id of your master

DO Form ZCHOOSE1 WITH  "SELECT MA_ID,MA_ACNAME FROM MASTER WHERE MA_ACNAME LIKE" ,oApp.sqlconnection,"ma_acname","str(ma_id)+' | '+ma_acname","MA_ID" TO LID


LID Variable will have to value of Ma_ID Field. So u will get the value back from form that what the user selected. Hope my tricks will help u! :)

posted Saturday, October 04, 2008 10:55 AM by vfpdotnet | 2 Comments
Filed Under:
Attachment(s): ZCHOOSE.ZIP

How to See the Changes in Sql Database Without Doing Requery/Refresh
These days most of guys changing the back end Database from vfp table to RDBMS. When we start developing software with msSql/mysql as backend. We face problem from our customers they keep u insist to make software same as they was using before in dos or vfp. Where he wants same  next previous first last buttons on same data entry screen. Now how u connect to RDMS in your forms. U have few options. But all can't see the changes in your database once you open the form. So For example in Hospital Doctor cant see the next patient in his prescription Data entry form until he close and open his form or press re query button and go thorough which are the new patient added. As All of Data access method just work as snapshot of database (Like ADO.NET). So After opening the form u don't know if the records are added, edited or deleted!.

Methods                       Shows u Exact Data
Remote Views                   Yes (required re query)
Sqlexec Query Table           
Yes (required re query)
CursorAdapter                  Yes (required re query)
ADO Control                    Yes (Only in dynamic cursor)  

So how we design our tables so we can always fresh tables. All experts say use parametrize forms why u need first next last buttons. Get value from user to search rather than those buttons. Hummm, we can understand but who go'na teach our customers?. he says i m paying you so do it for me. So its not much difficult either :) 

               Lets start with same Scenario We have OPD table which stores the daily patient record. At reception receptionist is registering the patient and doctor is giving his comments on same records. so how we can give doctor the real live data without closing and reopening the form. Lets see.

***First we get the last entered record.
=SQLEXEC(loSqlConnection,'Select max(pkKeyID) as PkKeyID FROM OPDTABLE','OPDMAIN')
**Make a Method in Form Give him the PkKeyID to display the record
ThisForm.ShowFreshRecord(OPDMAIN.PKKEYID)

METHOD : ShowFreshRecord
Lparameters pKeyID
*** Now we fetch the total record to show the record on form Bound ur form controls with this returned table.
=SQLEXEC(loSqlConnection,'Select FROM OPDTABLE where pkKeyID =?PKeyID' ,'OPD')
RETURN

So your form is displaying the Last Record. so now when this paitent gona outside and new paitent is coming in doctor's cabin. what will Doctor Do he will press the next button on form!.

METHOD : NextButton.Click
** We have to find the next entered record in database.
=SQLEXEC(loSqlConnection,'Select min(pkKeyID) as PkKeyID FROM OPDTABLE where pkKeyID >?OPDMAIN.PkKeyID ','OPDMAIN')
** We found the next record so we have to fresh the form now!
ThisForm.ShowFreshRecord(OPDMAIN.PKKEYID)

Now the previous patient come back to ask doctor about prescription. So doctor have to click on Prior Button!.

METHOD : PriorButton.Click
** We have to find the prior entered record in database.
=SQLEXEC(loSqlConnection,'Select max(pkKeyID) as PkKeyID FROM OPDTABLE where pkKeyID <?OPDMAIN.PkKeyID ','OPDMAIN')
** We found the prior record so we have to fresh the form now!
ThisForm.ShowFreshRecord(OPDMAIN.PKKEYID)

So by these tricks when ever doctor is moving in records he always have the fresh record and live database so he can see the all changes in database adding editing deleting!. Even we have not consumed the resources.  Hopes you like my tricks any more suggesstion or critic? your are welcome here..

 

posted Saturday, September 27, 2008 12:47 AM by vfpdotnet | 2 Comments
Filed Under:

Why you need Config.Fpw File?
Most of the programmers does not use the config.fpw file at least in INDIA where i live. The reason behind this most of the time we forget to make a config.fpw on client site. Some time application is running on 10+ computers so its need time to add config.fpw in all the computers. may be still some people around there who really dont know what is the purpose of config.fpw file?.
That is the configuration file for vfp. vfp reads it before starting so here we can specify the things the most common are by Rick Schummer which he wrote in his blog.

RESOURCE = OFF
ALLOWEXTERNAL = ON
_BROWSER = ""
_BUILDER = ""
_FOXREF = ""
_CONVERTER = ""
_COVERAGE
_GALLERY = ""
_GENGRAPH = ""
_GENHTML = ""
_GENMENU = ""
_GENPD = ""
_GENSCRN = ""
_GENXTAB = ""
_TASKPANE = ""
_TOOLBOX = ""
_TRANSPORT = ""
_WIZARD = ""

TMPFILES      = C:\TEMP
SORTWORK  = C:\TEMP
PROGWORK = C:\TEMP
INDEXWORK=C:\TEMP

ALLOWEXTERNAL  is just introduced in vf8 that gives us the power to include the config.fpw  in your project under others as a text file. But what if you need to use the new config.fpw file on client site? allowexternal command allow us to send a parameter for new config.fpw with your application. in the shortcut of your application u can specify the config.fpw file like

yourapplication.exe -cc:\yourfolder\config2.fpw

When you create your own custom OLE Automation servers, the OLE classes you create are delivered in either a .dll or an .exe file. Before you build the .exe or .dll, add the Config.fpw file into the project and make sure it is marked as included. At run time, the Config.fpw that resides inside of the .exe or .dll file is used. To specify a different Config.fpw file once an OLE Automation Server is distributed, you have   modify the registry key for the OLE server.  and have to add like this
 C:\temp\YourautomationExeFile.exe /automation -CC:\temp\CONFIG.FPW

The variables start with _ all are the vfp native variables which holds the file name by emptying these variables in vfp, Vfp runs faster well its a fraction of second fast :) but fast. and the tmpfile,sortwork progwork,indexwork these commands are very useful when u developing a application for multiuser enviornment.These Variables are good to use with foxpro for dos or OS  Prior To Windows XP.So when u making cursor or doing index vfp uses temporary files so these variables force vfp to make temporary files to the specific folder not on the network. That will increase the speed. Just make a config.fpw file in your production and include it into the project under others as text file. In case of Windows XP and Above windows is too smart to handle the data in windows temp folder automatically.

Those who use _screen.visible = .F. in there main.prg to overrid the main vfp window they shoule use command screen = off into the config.fpw file. Becaz. when u do _screen.visible in your Main.Prg your application opens and gives u a Flash! . So to elminate that flash use screen = off in your config.fpw file.


This is my entry in my blog. So not much having experince to write the Blog. So when u open your eyes that is the Morning For u! :)

posted Tuesday, September 16, 2008 5:30 AM by vfpdotnet | 2 Comments
Filed Under:
Attachment(s): CONFIG.ZIP

Powered by Community Server, by Telligent Systems