Solved

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

Posted on 2006-07-21
13
900 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
Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

717 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