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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to select from Access 1

Status
Not open for further replies.

StewartUK

Programmer
Feb 19, 2001
860
GB
I created a connection with the designer.

In there I set the Data source to Access, I enter the userid and in the Database textbox I entered "i:\newfred\import\gal.mdb". There is no password on the Access database.

When I click the Verify Connection button, I get a dialog box where I have to navigate to the database that I have already set!!

I have the "Display ODBC login prompts" set to "When login info is not specified".

Can someone tell me where I am going wrong?

Thanks,

Stewart
 
Just don't verify the connection!

Actually, as i recall, that's the default behavior. Do you need to do all that manually or can you just use SQLSTRINGCONNECT() instead?

Here's a snippet I use for importing recipe data from an .MDB:
Code:
lcDataBaseName = 'brew2'
lcMDBDir = 'C:\dave'
lcMDBName = 'BREWHAHA.MDB'
lnConnHandle = SQLSTRINGCONNECT('DSN=MS Access Database;DBQ='+;
  lcMDBDir+'\'+lcMDBName+';DefaultDir='+;
  lcMDBDir+';DriverId=25;FIL=MS Access;MaxBufferSize=2048;'+;
  'PageTimeout=5;UID=admin;')
Create data (lcDataBaseName)
SQLTABLES(lnConnHandle, ['TABLE'], 'myMDB')
Select myMDB
Scan
  lcSQL = 'select * from "'+trim(table_name)+'"'
  lcCursor = chrtran(trim(table_name),' ','_')
  lcTableName = '_'+lcCursor
  SQLEXEC(lnConnHandle,lcSQL,lcCursor)
  Select (lcCursor)
  Copy stru to (lcTableName)
  SCAN
     SCATTER memvar
     INSERT INTO (lcTableName) FROM memvar
  ENDSCAN
  USE IN (lcTableName)
  Add table (lcTableName)
Endscan
DO WHILE .T.
   IF SQLMoreResults(lnConnHandle) # 2
      WAIT WINDOW 'pause...' TIMEOUT 1
   ELSE
      EXIT
   ENDIF
ENDDO

SQLDISCONNECT(lnConnHandle)



-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top