Author | Topic: How to open Northwind.dbc from samples with Dacsession via odbcdbe | |
---|---|---|
Stacy Violett | How to open Northwind.dbc from samples with Dacsession via odbcdbe on Fri, 05 Dec 2014 20:05:24 +0100 Attempting to work through the process of opening vfp table with odbcdbe Following, find example that works opening table directly Second example attempts to use odbcdbe and fails. *example 1) Use table directly from .cxp works fine as follows: *-- code from an example in a cxp calle northwind.cxp <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859- 1"/> </head> <body> <h1>@('Hello')</h1> <p>The following should Display ID and Company from northwind customers table:</p> <% *northwind.cxp is sitting in xbase demo data folder along with northwind.dbc private jpath jpath:= ::PhysicalPath+"customers.dbf" USE (jpath) shared new ? 'Id: '+ customers->customerid+ ' Company: '+ customers- >companyname %> </body> </html> *-- exampple 2) problem, attempting to use a Dacsession and odbcdbe *-- code from an example in cxp called northwind_with_dacsession.cxp *-- this will error on line 15 Error: Operating system error in Line 15 Operating system error: this only occurs if the error cannot be identified otherwise. <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859- 1"/> </head> <body> <h1>@('Hello')</h1> <p>The following should Display a Ship Name from northwind orders table:</p> <% Ensure that ODBC DatabaseEngine is loaded and set as the default dbe IF !Dbeload( "ODBCDBE", .F. ) Alert( "ODBCDBE could not be loaded!" ) ENDIF DbeSetDefault( "ODBCDBE" ) /* Connect to DBC as defined by SOURCEDB; * use DELETED records, make visible in shared mode and use collation table "machine". */ cConnect := "DBE=ODBCDBE;DRIVER={Microsoft Visual FoxPro Driver};" cConnect += "SOURCETYPE=DBC;SOURCEDB=C:\Dev_Users\StacyV\xbase\amr_mob\xdata\northwind \dbf\northwind.dbc;Exclusive=No;" cConnect += "NULL=no;COLLATE=machine;BACKGROUNDFETCH=no;DELETED=no;" oSession := DacSession():New( cConnect ) Test for connection success IF .NOT. oSession:isConnected() ? "Error code :", oSession:getLastError() ? "Description:", oSession:getLastMessage() ELSE ? "Connection to server established." ENDIF Your data access code goes here... *northwind.cxp is sitting in xbase demo data folder along with northwind.dbc private csql cSQL := "SELECT customerid, companyname FROM Customers;" USE (cSQL) ALIAS Cust NEW ? 'Id: '+ customers->customerid+ ' Company: '+ customers- >companyname oSession:disconnect() %> </body> </html> | |
Stacy Violett | Re: How to open Northwind.dbc from samples with Dacsession via odbcdbe on Fri, 05 Dec 2014 20:10:16 +0100 Update - noticed a problem on line 43 and corrected. Also, going to attach my second example .cxp Stacy Violett wrote in message news:60c55e09$506a7ce2$74b6c@news.alaska- software.com... >Attempting to work through the process of opening vfp table with odbcdbe >Following, find example that works opening table directly >Second example attempts to use odbcdbe and fails. > > >*example 1) Use table directly from .cxp works fine as follows: >*-- code from an example in a cxp calle northwind.cxp > ><!DOCTYPE html> ><html> ><head> > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859- >1"/> ></head> ><body> > > <h1>@('Hello')</h1> > <p>The following should Display ID and Company from northwind customers >table:</p> > > <% > *northwind.cxp is sitting in xbase demo data folder along with >northwind.dbc > > private jpath > jpath:= ::PhysicalPath+"customers.dbf" > > USE (jpath) shared new > > ? 'Id: '+ customers->customerid+ ' Company: '+ customers- >>companyname > %> > ></body> ></html> > > > >*-- exampple 2) problem, attempting to use a Dacsession and odbcdbe >*-- code from an example in cxp called northwind_with_dacsession.cxp >*-- this will error on line 15 >Error: >Operating system error in Line 15 >Operating system error: this only occurs if the error cannot be identified >otherwise. > > ><!DOCTYPE html> ><html> ><head> > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859- >1"/> ></head> ><body> > > <h1>@('Hello')</h1> > <p>The following should Display a Ship Name from northwind orders >table:</p> > > <% > > Ensure that ODBC DatabaseEngine is loaded > and set as the default dbe > IF !Dbeload( "ODBCDBE", .F. ) > Alert( "ODBCDBE could not be loaded!" ) > ENDIF > DbeSetDefault( "ODBCDBE" ) > > /* Connect to DBC as defined by SOURCEDB; > * use DELETED records, make visible in > * shared mode and use collation table > * "machine". > */ > cConnect := "DBE=ODBCDBE;DRIVER={Microsoft Visual FoxPro Driver};" > cConnect += >"SOURCETYPE=DBC;SOURCEDB=C:\Dev_Users\StacyV\xbase\amr_mob\xdata\northwin d >\dbf\northwind.dbc;Exclusive=No;" > cConnect += >"NULL=no;COLLATE=machine;BACKGROUNDFETCH=no;DELETED=no;" > oSession := DacSession():New( cConnect ) > > Test for connection success > IF .NOT. oSession:isConnected() > ? "Error code :", oSession:getLastError() > ? "Description:", oSession:getLastMessage() > ELSE > ? "Connection to server established." > ENDIF > > Your data access code goes here... > *northwind.cxp is sitting in xbase demo data folder along with >northwind.dbc > > private csql > cSQL := "SELECT customerid, companyname FROM Customers;" > USE (cSQL) ALIAS Cust NEW > > > ? 'Id: '+ customers->customerid+ ' Company: '+ customers- >>companyname > > > oSession:disconnect() > > > %> > ></body> ></html> northwind_with_dacsession.cxp | |
Stacy Violett | Re: How to open Northwind.dbc from samples with Dacsession via odbcdbe on Thu, 11 Dec 2014 18:57:06 +0100 Alaska Software - not sure how to handle this post, but please know that my main development path has been answered here with some great help on another thread in your newsgroup. Any VFP developers wanting to know how to utilize VFP as a com dll should be directed to the following topic: Topic: Re: How to use DLL from within CXP Page This will help us get by while Polar Fox progresses. It has opened up a wonderful path to create DSNless connections for an API project we are working on here at Black Mountain Software. Thanks again, Stacy Please feel free to remove this thread if necessary, not sure how it should be handled. Stacy Violett wrote in message news:568f9f15$331c83fd$74c78@news.alaska- software.com... >Update - noticed a problem on line 43 and corrected. >Also, going to attach my second example .cxp > > > >Stacy Violett wrote in message news:60c55e09$506a7ce2$74b6c@news.alaska- >software.com... >>Attempting to work through the process of opening vfp table with odbcdbe >>Following, find example that works opening table directly >>Second example attempts to use odbcdbe and fails. >> >> >>*example 1) Use table directly from .cxp works fine as follows: >>*-- code from an example in a cxp calle northwind.cxp >> >><!DOCTYPE html> >><html> >><head> >> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859- >>1"/> >></head> >><body> >> >> <h1>@('Hello')</h1> >> <p>The following should Display ID and Company from northwind >customers >>table:</p> >> >> <% >> *northwind.cxp is sitting in xbase demo data folder along with >>northwind.dbc >> >> private jpath >> jpath:= ::PhysicalPath+"customers.dbf" >> >> USE (jpath) shared new >> >> ? 'Id: '+ customers->customerid+ ' Company: '+ customers- >>>companyname >> %> >> >></body> >></html> >> >> >> >>*-- exampple 2) problem, attempting to use a Dacsession and odbcdbe >>*-- code from an example in cxp called northwind_with_dacsession.cxp >>*-- this will error on line 15 >>Error: >>Operating system error in Line 15 >>Operating system error: this only occurs if the error cannot be >identified >>otherwise. >> >> >><!DOCTYPE html> >><html> >><head> >> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859- >>1"/> >></head> >><body> >> >> <h1>@('Hello')</h1> >> <p>The following should Display a Ship Name from northwind orders >>table:</p> >> >> <% >> >> Ensure that ODBC DatabaseEngine is loaded >> and set as the default dbe >> IF !Dbeload( "ODBCDBE", .F. ) >> Alert( "ODBCDBE could not be loaded!" ) >> ENDIF >> DbeSetDefault( "ODBCDBE" ) >> >> /* Connect to DBC as defined by SOURCEDB; >> * use DELETED records, make visible in >> * shared mode and use collation table >> * "machine". >> */ >> cConnect := "DBE=ODBCDBE;DRIVER={Microsoft Visual FoxPro >Driver};" >> cConnect += >>"SOURCETYPE=DBC;SOURCEDB=C:\Dev_Users\StacyV\xbase\amr_mob\xdata\northwi n >d >>\dbf\northwind.dbc;Exclusive=No;" >> cConnect += >>"NULL=no;COLLATE=machine;BACKGROUNDFETCH=no;DELETED=no;" >> oSession := DacSession():New( cConnect ) >> >> Test for connection success >> IF .NOT. oSession:isConnected() >> ? "Error code :", oSession:getLastError() >> ? "Description:", oSession:getLastMessage() >> ELSE >> ? "Connection to server established." >> ENDIF >> >> Your data access code goes here... >> *northwind.cxp is sitting in xbase demo data folder along with >>northwind.dbc >> >> private csql >> cSQL := "SELECT customerid, companyname FROM Customers;" >> USE (cSQL) ALIAS Cust NEW >> >> >> ? 'Id: '+ customers->customerid+ ' Company: '+ customers- >>>companyname >> >> >> oSession:disconnect() >> >> >> %> >> >></body> >></html> > > |