Vicki (or anyone else)
Do you know the correct syntax for connecting to a FoxPro database?
Right now I have to use dbConnectDSN which precludes me sending an install file to someone else.
I have not had any problem connecting to an Access database but I have never been able to figure out how to get dbConnect to work with FoxPro.
Larry
NOTE: Moved from Aurora section.
QuoteOPENCONSOLE
pointer pdb
pdb = dbConnect("Microsoft dbase VFP Driver (*.dbf)","c:\_browser test\db","")
IF pdb <> NULL
PRINT "Connection Established"
dbDisconnect(pdb)
else
print "Nope"
ENDIF
PRINT "Press any key to exit"
DO:UNTIL INKEY$ <> ""
CLOSECONSOLE
END
The driver and filename are both identical to what is entered in the DSN setup in control panel.
I enabled the ODBC log and get the following when I run the test program.
Quote
foxpro test a54-cd8 ENTER SQLAllocHandle
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 00000000
SQLHANDLE * 00147770
foxpro test a54-cd8 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 00000000
SQLHANDLE * 0x00147770 ( 0x008a1788)
foxpro test a54-cd8 ENTER SQLSetEnvAttr
SQLHENV 008A1788
SQLINTEGER 200 <SQL_ATTR_ODBC_VERSION>
SQLPOINTER 0x00000003
SQLINTEGER -6
foxpro test a54-cd8 EXIT SQLSetEnvAttr with return code 0 (SQL_SUCCESS)
SQLHENV 008A1788
SQLINTEGER 200 <SQL_ATTR_ODBC_VERSION>
SQLPOINTER 0x00000003 (BADMEM)
SQLINTEGER -6
foxpro test a54-cd8 ENTER SQLAllocHandle
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 008A1788
SQLHANDLE * 00147774
foxpro test a54-cd8 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 008A1788
SQLHANDLE * 0x00147774 ( 0x008a1830)
foxpro test a54-cd8 ENTER SQLDriverConnectW
HDBC 008A1830
HWND 00000000
WCHAR * 0x74329A38 [ -3] "******\ 0"
SWORD -3
WCHAR * 0x74329A38
SWORD 2
SWORD * 0x00000000
UWORD 0 <SQL_DRIVER_NOPROMPT>
foxpro test a54-cd8 EXIT SQLDriverConnectW with return code -1 (SQL_ERROR)
HDBC 008A1830
HWND 00000000
WCHAR * 0x74329A38 [ -3] "******\ 0"
SWORD -3
WCHAR * 0x74329A38
SWORD 2
SWORD * 0x00000000
UWORD 0 <SQL_DRIVER_NOPROMPT>
DIAG [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr). (0)
DIAG [01S00] [Microsoft][ODBC Visual FoxPro Driver]SourceType (0)
foxpro test a54-cd8 ENTER SQLFreeHandle
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 008A1830
foxpro test a54-cd8 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 2 <SQL_HANDLE_DBC>
SQLHANDLE 008A1830
foxpro test a54-cd8 ENTER SQLFreeHandle
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 008A1788
foxpro test a54-cd8 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
SQLSMALLINT 1 <SQL_HANDLE_ENV>
SQLHANDLE 008A1788
It said (see SQLSetEnvAttr). I looked that up and it might be telling somebody how to fix the problem but it's all Greek to me.
pdb = dbConnect("Microsoft dbase VFP Driver (*.dbf)","c:\_browser test\db","")
Should be:
pdb = dbConnect("Microsoft dbase VFP Driver (*.dbf)","c:\\_browser test\\db","")
Other than that I know nothing about Fox Pro, nor have any databases, so I have no way of testing it on my machine.
The new connect string from Paul should solve part of the problem if not all. I have a doc appointment but I'll look into the SQLSetEnvAttr when I get back. I shows in your print out that that finished with success but then there is the SQLHENV that I'm not sure about. I also don't have FoxPro and can't test it but I'll see if I can find some info for you. Should be back in a couple of hours. :)
putting the \\ in (proper way) didn't change anything
attached are some of the Foxpro dbase files I'm trying to conect to.
Just got in from the doc. I'll take a look at this soon as I can. Somewhere I have the connection strings for everything. I'll have a look and see what I can find.....below is a link to Visual FoxPro connection strings:
http://www.connectionstrings.com/?carrier=visualfoxpro
Vikki
Using information from the link you provided (along with what I could see in my DSN setup) I was able to get it to connect with the following :
QuotedbConnect("Microsoft dbase VFP Driver (*.dbf)","c:\\_browser test\\db","SourceType=DBF;Exclusive=No;Collate=Machine")
I'll have to modify some of my other coding to see if I can actually read the files but I don't expect to have any problem with that.
Thanks for supplying the info that got me over the hump. ;D
Larry
EDIT: Changed my program and it worked like a champ!
thanks again