?
Solved

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

Posted on 2006-07-21
13
Medium Priority
?
910 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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
 

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

777 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