Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: joe Degorio
  Where is joe Degorio?
 Tacloban City
 Philippines
 joe Degorio
 To: Biju Thomas
  Where is Biju Thomas?
 Kochi
 India
 Biju Thomas
 Tags
Subject: RE: Get data from Access Table in foxpro
Thread ID: 203305 Message ID: 203328 # Views: 44 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Thursday, November 13, 2008 7:03:46 AM         
   


> > 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

Hello Biju,
Thanks for sharing your ideas, I appreciate it very much. Just the idea I'm looking for...

regards,
joe



COMPLETE THREAD
Get data from Access Table in foxpro Posted by joe Degorio @ 11/13/2008 2:36:52 AM
RE: Get data from Access Table in foxpro Posted by Glenn Villar @ 11/13/2008 3:30:45 AM
RE: Get data from Access Table in foxpro Posted by Biju Thomas @ 11/13/2008 4:38:10 AM
RE: Get data from Access Table in foxpro Posted by joe Degorio @ 11/13/2008 7:03:46 AM
RE: Get data from Access Table in foxpro Posted by Biju Thomas @ 11/15/2008 3:30:15 PM