Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Connect to DBC database
Message
From
02/11/2023 08:23:03
 
 
To
02/11/2023 07:04:41
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01687153
Message ID:
01687171
Views:
52
>>>HI,
>>>
>>>I need to create a connection to Visual Foxpro DBC database for query specific table documentos and insert the result into Cursor for creating a new table on SQL server to insert the result of my cursor.
>>>This is my code:
>>
>>Luís,
>>
>>Why don't you just OPEN DATABASE and SELECT FROM whatever you need to extract, and INSERT whatever you need to add?
>>
>>Hi Antonio,
>>
>>Thanks for your reply.
>>My program is developed in VFP9 with a SQL Server database, so I can create a routine to connect to my client's old FoxPro database.
>>to pass data to my program, namely SQL Server, because my client's software is specifically for glassware.
>>
>>My problem is that I can't open the database from the client's software, I just need to collect the data from the invoice head table and the invoice line table from my programme.
>>The USE command of the table lock it, so I can't use this option or the other software will stop.
>>
>>Ideally, I'd like to be able to connect to the DBC database via ODBC and perform the necessary queries to pass the data to a cursor in VFP and make INSERTs in my SQL table.
>>
>>
>>Are there any of these possibilities?
>>Thank you
>>Luis
>Sounds like a missing Set Exclusive Off before the Use.
>
>Hi Tore,
>
>Thanks for your reply.
>
>Also, i have this coding to import Excel file into VFP Cursor:
>
>LOCAL lcXLBook AS STRING, lnSQLHand AS INTEGER, ;
>    lcSQLCmd AS STRING, lnSuccess AS INTEGER, ;
>    lcConnstr AS STRING
>CLEAR
>
>lcXLBook = [C:\SampleWorkbook.xlsx]
>
>lcConnstr = [Driver=] + ;
>    [{Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};] + ;
>    [DBQ=] + lcXLBook
>
>IF !FILE( lcXLBook )
>    ? [Excel file not found]
>    RETURN .F.
>ENDIF
>*-- Attempt a connection to the .XLSX WorkBook.
>*-- NOTE: If the specified workbook is not found,
>*-- it will be created by this driver! You cannot rely on a
>*-- connection failure - it will never fail. Ergo, success
>*-- is not checked here. Used FILE() instead.
>lnSQLHand = SQLSTRINGCONNECT( lcConnstr )
>
>*-- Connect successful if we are here. Extract data...
>lcSQLCmd = [Select * FROM "Sheet1$"]
>lnSuccess = SQLEXEC( lnSQLHand, lcSQLCmd, [xlResults] )
>? [SQL Cmd Success:], IIF( lnSuccess > 0, 'Good!', 'Failed' )
>IF lnSuccess < 0
>    LOCAL ARRAY laErr[1]
>    AERROR( laErr )
>    ? laErr(3)
>    SQLDISCONNECT( lnSQLHand )
>    RETURN .F.
>ENDIF
>
>
>*-- Show the results
>SELECT xlResults
>BROWSE NOWAIT
>SQLDISCONNECT( lnSQLHand )
>
>
>
>I need to know how do i change the connection string to connect to DBC or DBF file to do the same.
>Is it possible, because this approach work very well and fast for Excel.
>
>Many Thanks,
>Luis

I can't help you with the ODBC part.

I just don't understand why you need to complicate things? If I understand correctly, you want a VFP application to read data from another VFP application? If that's correct, why don't you simply run a SQL statement to read the data? Why do you think that you have to use ODBC?
Previous
Reply
Map
View

Click here to load this message in the networking platform