Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Can VBScript read foxpro 2.6 database?

Reply
 
Old 08-05-2009   #1 (permalink)
C.K


 
 

Can VBScript read foxpro 2.6 database?

i have a system work in dos and foxpro 2.6
now i hope get that data on website
can vbscript do that? and how?



My System SpecsSystem Spec
Old 08-05-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Can VBScript read foxpro 2.6 database?


"C.K" <accin@xxxxxx> wrote in message
news:eV4CLcjFKHA.4932@xxxxxx
Quote:

>i have a system work in dos and foxpro 2.6
> now i hope get that data on website
> can vbscript do that? and how?
>
VBScript can use OLE DB or ODBC drivers to access databases. You need a
connection string. See this link for information on connection strings for
FoxPro 2.x:

http://www.connectionstrings.com/visual-foxpro

I have no experience with FoxPro, but I would use ADO in code similar to
below:
========
' Connection string. In this case, the database is c:\myvfpdb.dbc.
strConnect = "Driver={Microsoft Visual FoxPro Driver};" _
& "SourceType=DBC;" _
& "SourceDB=c:\myvfpdb.dbc;" _
& "Exclusive=No;" _
& "NULL=NO;" _
& "Collate=Machine;" _
& "BACKGROUNDFETCH=NO;" _
& "DELETED=NO;"

' Open a connection to the database.
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.ConnectionString = strConnect
adoConnection.Open

' Query a table in the database.
Set adoRecordset = CreateObject("ADODB.Recordset")
Set adoRecordset.ActiveConnection = adoConnection
adoRecordset.Source = "SELECT * FROM MyTable"
adoRecordset.Open

' Enumerate the resulting recordset.
' Retrieve all fields for all rows.
j = 0
Do Until adoRecordset.EOF
j = j + 1
for k = 1 To adoRecordset.Fields.Count
strValue = adoRecordset.Fields(k - 1).Value
strName = adoRecordset.Fields(k - 1).Name
Wscript.Echo j & ", " & k & ": " & strName & " = " & strValue
Next
adoRecordset.MoveNext
Loop

' Clean up.
adoRecordset.Close
adoConnection.Close
=======
My example above assumes you know a table name, but not the names of the
fields, so it enumerates the names and values of all fields. Generally, you
will know the names of the fields, so the query and recordset enumeration
may be more similar to:
========
' Query specific fields in specific rows.
adoRecordset.Source = "SELECT FirstName, LastName FROM MyTable " _
& "WHERE RoomID = 34"

Do Until adoRecordset.EOF
strFirst = adoRecordset.Fields("FirstName").Value
strLast = adoRecordset.Fields("LastName").Value
Wscript.Echo strFirst & " " & strLast
adoRecordset.MoveNext
Loop
=======
This demonstrates how a VBScript program can use ADO to read any database,
if you can create a valid connection string, and you know something about
the database. Getting this on a web site is another matter, and is up to
you. I hope this helps.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to read sql server database properties PowerShell
Read txt file and compare to database VB Script
Cannot connect to FoxPro database in Vista, IIS 7 General Discussion
interesting read> media player database Vista General
I have a problem creating a ODBC connection to a Foxpro Database!! Vista file management


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46