Link to home
Start Free TrialLog in
Avatar of Stanley Lai
Stanley LaiFlag for Hong Kong

asked on

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

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
Avatar of Mr_Peerapol
Mr_Peerapol

I would suggest you access FoxPro through ODBC.
In more detail:

Create System DSN

EXEC sp_addlinkedserver
   @server = 'LinkedServerName',
   @provider = 'MSDASQL',
   @datasrc = 'Your System DSN'
Avatar of Stanley Lai

ASKER

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
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 ...




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
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.

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
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')
OK .... understand ... let me try and come back to you ...

ASKER CERTIFIED SOLUTION
Avatar of Mr_Peerapol
Mr_Peerapol

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nothing can be say .... you are really great !!  I really mean it.

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

Cheers
Stanley
it works and even no DSN required !!  ^_^
So you need to hard-code the file location.
Anyway, I'm glad that helps.