Connecting Tech Pros Worldwide Help | Site Map

ASP connection to visual foxpro

  #1  
Old October 22nd, 2008, 04:25 AM
jagvrb@aol.com
Guest
 
Posts: n/a
I am trying to setup an active server page that accesses my visual
foxpro database. I have setup a system DSN named vfp_test. How do you
open a recordset in an ASP? I have tried this code: rs.Open "ICILOC",
"DSN=VFP_test" , but I get an error on that line.
  #2  
Old October 22nd, 2008, 11:55 AM
Bob Barrows [MVP]
Guest
 
Posts: n/a

re: ASP connection to visual foxpro


jagvrb@aol.com wrote:
Quote:
I am trying to setup an active server page that accesses my visual
foxpro database. I have setup a system DSN named vfp_test. How do you
open a recordset in an ASP? I have tried this code: rs.Open "ICILOC",
"DSN=VFP_test" , but I get an error on that line.
First, create and open a connection object:
set cn=createobject("adodb.connection")
'if vfp has an native ole db provider you should use it
'see www.connectionstrings .com
'for the sake of this example I will use your DSN
cn.open "VFP_test"

Then create a sql statement to only retrieve the fields you plan to use from
iciloc which I assume is the name of the table.
sql="select filed1,...,fieldN from iciloc"

Be explicit - don't use selstar in production code:
http://www.aspfaq.com/show.asp?id=2096

Then, to open a recordset using the default server-side, forwardonly cursor:
set rs = cn.execute(sql,,1)

The 1 means adCmdText - you should always tell ADo what the command type is.

--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting to FoxPro from .NET z71mdridin answers 7 January 4th, 2008 06:55 PM
problem with the connection to the db armando answers 1 February 2nd, 2007 02:05 PM
Migrated website, now ASP that access Foxpro data doesn't work Colin Colin answers 2 July 19th, 2005 02:55 PM
Querying More Than 255 Characters from FoxPro/DBase Database Field Matt Young answers 4 July 19th, 2005 11:35 AM