> Hello Everyone,
> I'm running a VB application within my Foxpro application, The Vb part is just entering some data and saving it to its access table, How can I display every record(from access table) to my foxpro grid everytime its saves.(similar like a data logger), I can get the data from access table but I need to close my form and open it again to update the content of the grid. Hope anybody can help me...:)
>
>
> Thanks in advance,
> joe
Dear Joe
Simply create a system DSN – Microsoft Access driver (mbd)and the data source name as “mydatabase”. No need to connect it to any database at all.
Create a form
In the Init enter
Public mydatasource
create a command button name it as connect. In the click event
If mydatasource <= 0
cDsnName = "mydatabase"
cPwd = 'mypassword'
cDb= "mydatabase.mdb" && with full path
If !File(cDb)
Error Message here
Return
Endif
aAnnStr = "DSN=" + cDsnName + ";DBQ=" + cDb + ";DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;PWD=" + cPwd + ";UID=admin;"
Store Sqlstringconnect(aAnnStr) To mydatasource
If mydatasource <= 0
Messagebox('No connection',0,'')
Endif
Endif
In the Right Click Event (To disconnect)
If mydatasource > 0
aAnn =SQLDisconnect(mydatasource)
Store -1 To mydatasource
Endif
Save and run click on the command button
Open your data form go to dataenvironment window.
Now from the dataenvironment select Add cursoradaptor, right click on the cursor adaptor select builder. In the very 1st page select Data Source Type :ODBC. Then select Use exsisiting connection handle, enter mydatasource in Capital letter. Then go to page 2 Data Access. Select Build. Your tables from the database will be there. Enjoy the rest.
You can store the connection and disconnection procedures in a class and use it when you call your data form.
Do not forget to disconnect from the data source after your work is completed.
Now think about the possibilities of variable 'cDb'. You can store the data path or path to the your database in a field and retrive it. This means you can place your databases to any location you wish. Simply update the new location through a program if it is changed by the user, means the database is shifted to a new location.
With Regards,
Biju Thomas