Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Canada
 Pete Sass
 To: Craig Moore
  Where is Craig Moore?
 
 United Kingdom
 Craig Moore
 Tags
Subject: Connect in VFP Code to Access mdb "Close"
Thread ID: 21774 Message ID: 21785 # Views: 39 # Ratings: 0
Version: Visual FoxPro 8 Category: ODBC, ADO and OLEDB
Date: Tuesday, April 01, 2003 6:03:02 PM         
   


Hi,

Well here is the code I am using to test with:
CLOSE DATABASES ALL
OPEN DATABASE SCALES SHARED
dbLocation = 'D:\Scales\Chip_db.mdb'
STORE SQLSTRINGCONNECT('DSN=Chip_Scale;DBQ='+dbLocation+';Driveld=281;FIL=MS Access;Max Buffer Size=2048 Page Timeout=5;UID=admin;PWD=secretcode;') TO gnConnHandle
IF gnConnHandle < 0
= MESSAGEBOX('Cannot make connection', 16, 'SQL Connect Error')
ELSE
= MESSAGEBOX('Connection made', 48, 'SQL Connect Message')
= SQLDISCONNECT(gnConnHandle)
ENDIF

This code establishes the connection OK....
But I am trying to do two things with it.
1. Get it into a database container and utilize as a shared connection for remote views.
2. Surpress the login prompts from happening.

The code I was previously using, added the connection into the database and
surpresses the login prompts.

Pete,



> can't you build up a string like
>
> pcMdbLoc = 'D:\Scales\Chip_db.mdb'
>
> lcConString = 'DSN=Chip_Scale;DBQ='+pcMdbLoc+';Driveld=281;FIL=MS Access;Max Buffer Size=2048 Page Timeout=5;PWD=thepassword;uid=admin;'
>
> STORE SQLSTRINGCONNECT(&lcConString) TO gnConnHandle
>
> = SQLDISCONNECT(gnConnHandle)
>
> or something like this, is this what you are after or am I way of track?
>
> Craig
>
>
>
>
>
> > Hi,
> > Building an application and started using code to setup the connection and
> > with code add the remote view tables.
> >
> > Example of connection code:
> >
> > * --- DATACONN.PRG - To programically connect to a backend database
> > * --- Peter Sass, 2003.03.06
> > * --- Have to open the database first
> > CLOSE DATABASES ALL
> > OPEN DATABASE SCALES SHARED
> >
> > * --- Now Create the connection
> > CREATE CONNECTION Chipconn DATASOURCE "Chip_Scale" USERID "Admin" PASSWORD "thepassword"
> >
> > * --- Set the ODBC Login prompt to never prompt you
> > DBSetProp('chipconn','Connection','DispLogin', 3)
> >
> >
> > What I want to do is use a connection string in code and the connection string for
> > this actual connection is :
> > DSN=Chip_Scale;DBQ=D:\Scales\Chip_db.mdb;Driveld=281;FIL=MS Access;Max Buffer Size=2048;
> > Page Timeout=5;PWD=thepassword;uid=admin;
> >
> > What I am trying to do is use the string to connect so I can somehow get into the
> > "DBQ=D:\Scales\Chip_db.mdb" portion of the string and treat this part as a memory
> > variable that I can change. So if the Access database location moves to a different
> > location on the server, a global setup module change change a memory variable
> > holding the DBQ path will wash into the connection string and change it there.
> >
> > Any ideas out there ??????? or examples of connection string code using a
> > memory variable within the string that can be changed ???????
> >
> >
> > Pete from the Great White North. (Only in Canada, ay.) Over and Out ...


Pete from the Great White North. (Only in Canada, ay.) Over and Out ...


COMPLETE THREAD

Connect in VFP Code to Access mdb? Posted by Pete Sass @ 4/1/2003 3:39:20 PM
RE: Connect in VFP Code to Access mdb? Posted by Craig Moore @ 4/1/2003 4:29:04 PM
Connect in VFP Code to Access mdb "Close" Posted by Pete Sass @ 4/1/2003 6:03:02 PM
RE: Connect in VFP Code to Access mdb "Got it !" Posted by Pete Sass @ 4/1/2003 7:54:37 PM