Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting to FoxPro database ? 1

Status
Not open for further replies.

Webwzrd

Programmer
Apr 23, 2002
40
US
Could someone please give me a simple example of how to connect to a foxpro database ?

Thanks in advance !!!
 
Hi there,

I'm using visual foxpro 7. Here is the code snippet:

----------------------

Imports System.Data
Imports System.Data.OleDb

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

Dim oConn As OleDbConnection
Dim sConnString As String
Dim oCmd As OleDbCommand
Dim oDR As OleDbDataReader
Dim strSQL As String = "select * from accounts"

'FoxPro database connection
sConnString = "provider=VFPOLEDB.1 ;data source= 'C:\...\mydatabase.DBC';password='';user id=''"
oConn = New OleDbConnection(sConnString)
oCmd = New OleDbCommand(strSQL, oConn)

Try
oConn.Open()
'then do something here...., like:
'oDR = oCmd.ExecuteReader()

Catch exc As OleDbException
Response.Write(exc)
Finally
oCmd.Dispose()
If oConn.State = ConnectionState.Open Then
oConn.Close()
End If
oConn.Dispose()
End Try
End sub
 


What if the database is on another server ?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top