Solved

What is the "Provider Name" for foxpro DB when using openrowset in SQL select ?

Posted on 2006-07-21
13
868 Views
Last Modified: 2011-10-03
I'm now writing a two-way query between MS SQL server & foxpro DB.

On MS SQL server, I need to access both tables on SQL server as well as on foxpro DB using SQL select statement.  From the SQL Server Books Online (search Transact-SQL Reference "OPENROWSET"), I can find my expected syntax.  However, in the OPENROWSET command, the first parameter is "provider name" .... I'm now required to access DB in Visual Foxpro 6.0 DB, what is the "provider name" for this ?  Please also, advise how can one search such name ?  Thanks.

Can anyone help ?

Cheers
StanleyLMW
0
Comment
Question by:StanleyLMW
  • 7
  • 6
13 Comments
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17152342
I would suggest you access FoxPro through ODBC.
0
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17152353
In more detail:

Create System DSN

EXEC sp_addlinkedserver
   @server = 'LinkedServerName',
   @provider = 'MSDASQL',
   @datasrc = 'Your System DSN'
0
 

Author Comment

by:StanleyLMW
ID: 17152515
Hi Mr Peerapol,

Actually, I do not insist to use OLE DB, just can complete my job will be fine ^.^

I'm not quite clear on your ODBC method.  I do created an ODBC file DSN to access both for specific SQL server Database (here I name it as SSS.DSN, it access a database named SSS on my SQL server and the connection verified to be OK) and Foxpro DB (here I name it TRANHIST.DSN, it access a folder on my server which contain the related foxpro DBs).

Then, in my stored procedure, I want to access a SQL table named CLIENT under the SQL SSS database and a FOXPRO TRANHIST.DBF under the server folder mentioned above.  What should I do in my stored procedure in order to compose my SELECT statement and to access those tables via ODBC ?  e.g.

SELECT * from xxxxxxxx.CLIENT LEFT OUTER JOIN yyyyyyyyyyy.TRANHIST ON ...............

Kindly please advise.

Cheers
StanleyLMW
0
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17152559
You don't need to create DSN for SQL Server. Just execute the sp_addlinkedsever above for Foxpro. Then you can do like this:

SELECT c.*, f.*
FROM SSS.dbo.CLIENT c LEFT OUTER JOIN OPENQUERY(LinkedServerName, 'SELECT somefields FROM foxpro_table') f ON ...




0
 

Author Comment

by:StanleyLMW
ID: 17152764
Hi Mr Peerapol,

My company's setting is really more than stubborn ... even in testing environment, they do not allow us to create linked server .... !!!  They say that even in production, they try not to link any SQL servers.  As a result, even I can test it at home and find to be OK, I still can not put it on production .... :(

.... any other methods can be use ?

Regards,
Stanley
0
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17152933
Do they allow you to create DNS? If yes, can you try using OPENROWSET and passing 'MSDASQL' as a provider name?
Otherwise, I'm sorry to say I have no idea.

0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 

Author Comment

by:StanleyLMW
ID: 17165635
Hi Mr Peerapol,

You mean System/User/File DSN ?  Yes.  They allow.  Yet, but using 'MSDASQL' as the provider name can access Foxpro database or not ?  I'm not that familiar with the syntax of OPENROWSET, may you suggest the what I should type into the OPENROWSET as the parameters ?

Cheers
Stanley
0
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17165809
I never tried FoxPro before. So I'm not sure it will work for you.

Create the system DSN first (you should specify username/password here), then try this:

SELECT *
FROM OPENROWSET('MSDASQL', 'DSN_goes_here', 'SELECT somefieds FROM foxpro_table')
0
 

Author Comment

by:StanleyLMW
ID: 17165819
OK .... understand ... let me try and come back to you ...

0
 
LVL 25

Accepted Solution

by:
Mr_Peerapol earned 500 total points
ID: 17165849
I got this from internet. It might be useful for you. I think no DSN is required by below methods:


SELECT a.*
 FROM OPENROWSET('MSDASQL',
 'DRIVER={Microsoft Visual FoxPro Driver};
 Exclusive=No;Collate=Machine;Deleted=Yes;Null=No;
 SourceDB=d:\data\MyDatabase.dbc;SourceType=DBC;',
 'SELECT * FROM MyTable') AS a


SELECT * FROM OPENROWSET('MSDASQL', 'DRIVER={Microsoft foxpro vfp Driver
(*.dbf)};UID=;Deleted=No;Null=No;Collate=Machine;BackgroundFetch=No;Exclusive=No;SourceType=DBF;SourceDB=c:\abc', 'SELECT * FROM T_MWKNO')
0
 

Author Comment

by:StanleyLMW
ID: 17165871
Nothing can be say .... you are really great !!  I really mean it.

million million thanks.... ... .... ...  ..... thanks.

Cheers
Stanley
0
 

Author Comment

by:StanleyLMW
ID: 17165875
it works and even no DSN required !!  ^_^
0
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17165984
So you need to hard-code the file location.
Anyway, I'm glad that helps.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now