dbTalk Databases Forums  

Connecting to SQL Server 2008 Express Databases from Visual FoxPro 9

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Connecting to SQL Server 2008 Express Databases from Visual FoxPro 9 in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gene Wirchenko
 
Posts: n/a

Default Connecting to SQL Server 2008 Express Databases from Visual FoxPro 9 - 03-11-2011 , 05:16 PM






Dear SQLers:

The subject about says it all. How do I do this?

My SQL Server 2008 Express system is LOOP\SQLEXPRESS.

Apparently, I should create an ODBC connection. I have no idea
how to do this.

If you only know the SQL Server side, please reply with that
side. That is more than what I know.

Sincerely,

Gene Wirchenko

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Connecting to SQL Server 2008 Express Databases from Visual FoxPro 9 - 03-12-2011 , 06:00 AM






Gene Wirchenko (genew (AT) ocis (DOT) net) writes:
Quote:
The subject about says it all. How do I do this?

My SQL Server 2008 Express system is LOOP\SQLEXPRESS.

Apparently, I should create an ODBC connection. I have no idea
how to do this.

If you only know the SQL Server side, please reply with that
side. That is more than what I know.
You use sp_addlinkedserver to define a linked server. If authentication
is requireed, you may also need to set up login mapping with
sp_addlinkedsrvlogin.

Once you have this set up, you can query the FoxPro database using
four-part notation, for instance "SELECT * FROM SERVER.db..tbl".

If there is an OLE DB provider for Foxpro, use that one. Else you can
use the MSDASQL provider - that is OLE DB over ODBC - and any the ODBC
driver for Foxpro there might be.

I suspect that Google can be helpful.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Reply With Quote
  #3  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Connecting to SQL Server 2008 Express Databases from Visual FoxPro 9 - 03-13-2011 , 09:23 PM



On Sat, 12 Mar 2011 13:00:16 +0100, Erland Sommarskog
<esquel (AT) sommarskog (DOT) se> wrote:

Quote:
Gene Wirchenko (genew (AT) ocis (DOT) net) writes:

The subject about says it all. How do I do this?

My SQL Server 2008 Express system is LOOP\SQLEXPRESS.

Apparently, I should create an ODBC connection. I have no idea
how to do this.

If you only know the SQL Server side, please reply with that
side. That is more than what I know.

You use sp_addlinkedserver to define a linked server. If authentication
is requireed, you may also need to set up login mapping with
sp_addlinkedsrvlogin.

Once you have this set up, you can query the FoxPro database using
four-part notation, for instance "SELECT * FROM SERVER.db..tbl".
I want to query *from* VFP *to* SQL Server.

(Why is it that so many people do not read the title of posts?
Why is it that I forgot this?)

Quote:
If there is an OLE DB provider for Foxpro, use that one. Else you can
use the MSDASQL provider - that is OLE DB over ODBC - and any the ODBC
driver for Foxpro there might be.

I suspect that Google can be helpful.
No. I do not know enough to know what to look for, so it just
gets me swamped.

Sincerely,

Gene Wirchenko

Reply With Quote
  #4  
Old   
Jason Keats
 
Posts: n/a

Default Re: Connecting to SQL Server 2008 Express Databases from Visual FoxPro9 - 03-14-2011 , 12:33 AM



Gene Wirchenko wrote:
Quote:
On Sat, 12 Mar 2011 13:00:16 +0100, Erland Sommarskog
esquel (AT) sommarskog (DOT) se> wrote:

Gene Wirchenko (genew (AT) ocis (DOT) net) writes:

The subject about says it all. How do I do this?

My SQL Server 2008 Express system is LOOP\SQLEXPRESS.

Apparently, I should create an ODBC connection. I have no idea
how to do this.

If you only know the SQL Server side, please reply with that
side. That is more than what I know.

You use sp_addlinkedserver to define a linked server. If authentication
is requireed, you may also need to set up login mapping with
sp_addlinkedsrvlogin.

Once you have this set up, you can query the FoxPro database using
four-part notation, for instance "SELECT * FROM SERVER.db..tbl".

I want to query *from* VFP *to* SQL Server.

(Why is it that so many people do not read the title of posts?
Why is it that I forgot this?)

If there is an OLE DB provider for Foxpro, use that one. Else you can
use the MSDASQL provider - that is OLE DB over ODBC - and any the ODBC
driver for Foxpro there might be.

I suspect that Google can be helpful.

No. I do not know enough to know what to look for, so it just
gets me swamped.

Sincerely,

Gene Wirchenko
I haven't used Visual Foxpro, but I have used VB with SQL Server. I'm
pretty sure it's similar.

You don't say whether you're trying to connect to SQL Server on a local
or remote machine. In either case, you'll probably want to configure the
TCP/IP protocol. You will probably also want to enable remote connections.

There are plenty of articles that discuss the above. For example:
http://www.linglom.com/2009/03/28/en...-2008-express/
http://blogs.msdn.com/b/bethmassi/ar...-on-vista.aspx

Part 10 of the above article discusses connection strings.

More information about connection strings can be obtained at:
http://www.carlprothman.net/Default.aspx?tabid=81
http://www.connectionstrings.com/

I tend to use ADO with an OLEDB provider, rather than ODBC.

HTH

Reply With Quote
  #5  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Connecting to SQL Server 2008 Express Databases from Visual FoxPro 9 - 03-14-2011 , 02:53 AM



Gene Wirchenko (genew (AT) ocis (DOT) net) writes:
Quote:
I want to query *from* VFP *to* SQL Server.

(Why is it that so many people do not read the title of posts?
Why is it that I forgot this?)
Because this is an SQL Server newsgroup, and your question is about Visual
FoxPro?

I have no idea how you connect to remote data sources in Visual FoxPro. In
fact my knowledge about FoxPro is about zero.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
  #6  
Old   
Viorel Nacu
 
Posts: n/a

Default Re: Connecting to SQL Server 2008 Express Databases from Visual FoxPro 9 - 03-14-2011 , 07:27 AM



Hi Gene,

You should have a dbc created for all work with that sql server.
On the dbc you can create manually a connection to your server or using the
following command only once (with the dbc open)

create connection yourconn connstring "DRIVER=SQL
Server;SERVER=yourservername;UID=username;PWD=pass word;DATABASE=yourdatabasename"

Once you have the connection created you can create remote view on the dbc
and use like regular foxpro tables or use the following command to get data
from sql server on foxpro cursors
Open a connection to sql server
myconn = sqlconnect('yourconn')
To verify if connection is ok
? myconn
If positive is ok
If negative be sure that you enabled remote connection and at least the
TCP/IP protocol on the sql server.
Get data from sql server
=sqlexec(myconn, "select * from somesqltabel", "vfpcursor")

You can reuse the connection for multiple commands.

When you do not need it anymore close the connection with
=sqldisconnect(myconn)

If you need any other connection just pay a visit to
http://www.connectionstrings.com/


Regards,

Viorel


"Erland Sommarskog" <esquel (AT) sommarskog (DOT) se> wrote

Quote:
Gene Wirchenko (genew (AT) ocis (DOT) net) writes:
I want to query *from* VFP *to* SQL Server.

(Why is it that so many people do not read the title of posts?
Why is it that I forgot this?)

Because this is an SQL Server newsgroup, and your question is about Visual
FoxPro?

I have no idea how you connect to remote data sources in Visual FoxPro. In
fact my knowledge about FoxPro is about zero.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
  #7  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Connecting to SQL Server 2008 Express Databases from Visual FoxPro 9 - 03-14-2011 , 12:56 PM



On Mon, 14 Mar 2011 08:53:03 +0000 (UTC), Erland Sommarskog
<esquel (AT) sommarskog (DOT) se> wrote:

Quote:
Gene Wirchenko (genew (AT) ocis (DOT) net) writes:
I want to query *from* VFP *to* SQL Server.

(Why is it that so many people do not read the title of posts?
Why is it that I forgot this?)

Because this is an SQL Server newsgroup, and your question is about Visual
FoxPro?
My question is about both. You just got the direction wrong.

Quote:
I have no idea how you connect to remote data sources in Visual FoxPro. In
fact my knowledge about FoxPro is about zero.
I figure that it is similar between different languages, but I do
not know that it is not necessary to do something in SQL Server first
to make the data accessible. I need both pieces.

Sincerely,

Gene Wirchenko

Reply With Quote
  #8  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Connecting to SQL Server 2008 Express Databases from Visual FoxPro 9 - 03-14-2011 , 03:35 PM



Gene Wirchenko (genew (AT) ocis (DOT) net) writes:
Quote:
I figure that it is similar between different languages, but I do
not know that it is not necessary to do something in SQL Server first
to make the data accessible. I need both pieces.
Connecting from Visual FoxPro is nothing different than connecting from
SQL Server Management Studio or any other application. You need to
have a valid login and if you connect from a different machine, SQL Server
must accept connections over TCP/IP or named pipes, and there must not
be any firewall in the way.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Reply With Quote
  #9  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Connecting to SQL Server 2008 Express Databases from Visual FoxPro 9 - 03-14-2011 , 05:05 PM



On Mon, 14 Mar 2011 22:35:16 +0100, Erland Sommarskog
<esquel (AT) sommarskog (DOT) se> wrote:

Quote:
Gene Wirchenko (genew (AT) ocis (DOT) net) writes:
I figure that it is similar between different languages, but I do
not know that it is not necessary to do something in SQL Server first
to make the data accessible. I need both pieces.

Connecting from Visual FoxPro is nothing different than connecting from
SQL Server Management Studio or any other application. You need to
have a valid login and if you connect from a different machine, SQL Server
must accept connections over TCP/IP or named pipes, and there must not
be any firewall in the way.
Thank you. Some of the blur that I tried to follow seemed to
indicate the opposite. Sometimes, the Web is rather sticky.

Sincerely,

Gene Wirchenko

Reply With Quote
  #10  
Old   
i79947@fake.uwasa.fi.invalid
 
Posts: n/a

Default Re: Connecting to SQL Server 2008 Express Databases from Visual FoxPro 9 - 03-16-2011 , 03:51 AM



In microsoft.public.sqlserver.programming Gene Wirchenko <genew (AT) ocis (DOT) net> wrote:
Quote:
Dear SQLers:

The subject about says it all. How do I do this?

My SQL Server 2008 Express system is LOOP\SQLEXPRESS.

Apparently, I should create an ODBC connection. I have no idea
how to do this.
Search VFP help for "ODBC". You should get more that enough information.
--
JS

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.