Actually it's real easy... after you've done it a couple of times. The first time you tend to get lost.
Anyway, you first create an ODBC connection in windows to your database. This is done through Start/Settings/Control Panel. In Win 9x there's a separate ODBC setup icon. In Win 2000 you have to open the Administrative Tools folder in the Control Panel to find it "Data Sources(ODBC)"
Use either the first or second tab (depending on whether there are other uses who need your data source or not) and click 'add. ' This lets you select what sort of database you're connecting to. Then you have to fill in the data in the next screen and test it.
After that, you can create a remote view in VFP using that data source. When you do this you can either create connections first and then use them to create the remote view, or click the radio button for data sources and select the Windows data source you created.
the above code will allow you to connect to an SQL server without an ODBC DSN entry
here is an explanation of what is going on
DRIVER:
this Driver entry allows you to define the specfic ODBC or OLEDB driver to use in order to connect to a database.
Server:
this is the Server destantion the Netbois, IP address, or DNS name.
Trusted_Connection:
this feature allows you to grab the current log on user to the computer. No extra code is needed.
This only works to my knowlegde with SQL server which can intergate into NT securtiy.
I use this feature allot. It works on 98 NT4.0 and W2K i know this because that is what we run.
If you can not use trusted_Connection
Simply replace with uid= and Pwd= this assums that the user has access to the Database and Server.
DATABASE:
is the remote database name located on the SQL server
App:
this is the name of the application as it will appear on the SQL server
lnDSNless:
is the connection handle which if everything worked correctly came back with a Possitive integer, anything less than 0 it failed. so do a test,el like so
IF lnDSNless < 0
wait window "I failed to connect to the DATABASE oh SHIT" timeout 5
else
my_code_stuff()
endif
If you don't like useing dsnless connection. simply use a predefine ODBC dsn.
then call it like so
lnConnect = SQLConnect("AN_ODBC_DSN"
If lnConnect < 0
wait window "I failed to connect to the DATABASE oh SHIT" timeout 5
else
my_code_stuff()
endif
This above code is example on how to connect to a remote databse via SQL Passthrough
it is not as easy to code but far faster and can run the Database native laugauge
The following command are helpful in SQL Passthrough and are required
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.