lcDSNless= "DRIVER=SQL Server;SERVER=DATA_SERVER;Trusted_Connection=Yes;DATABASE=FoxproApps;APP=MyFoxPro"
lnDSNless = SqlStringConnect(lcDSNless)
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
SqlCancle()
SqlColums()
SQLCommit
SQLConnect()
SqlDisconnect()
SQLEXEC()
SQLGETPROP()
SQLMORERESULTS()
SQLPreapre()
SqlRollBack()
SqlSetPROP()
SqlStringConnect()
SqlTables()
All these command are avaible in 5.0 6.0 and 7.0
all these commands work best on SQL SERVER.
If you cannot figure out how to use SQL PassThrough go with remote views.
I personal hate remote views becasue there so dam slow, but are easy to use. Also 7.0 ships with an SQL Passthrough class libary
Hope this is helps
my e-mail is justin@emproshunts.com
I can send you some code examples