Connecting Foxpro to SQL Server 2005

I am trying to connect to a SQL Server 2005 database Spain.mdf.  

I am using a variant of the code I am using for connection to Access tables:

lcmyfile = "c:\spain.mdf"
lnconnhandle = ;
   SQLSTRINGCONNECT('DRIVER={SQL SERVER} (*.MDF); DBQ=' + lcmyfile)

Access works fine.   My Excel routine works file, SQL bombs.

Any ideas
fmoore0001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tusharkanvindeCommented:
Try

SQLSTRINGCONNECT('Driver={SQL Server};;AttachDbFilename=c:\spain.mdf;Server=localhost;Database=spain;Trusted_connection=yes')

Are you using SQL Server or SQL Server Express.
0
fmoore0001Author Commented:
tusharkanvinde,

That got me further than I have did.  I got a login error, then I relogged, and got this error:

Connection Failed:
SQLState: 'S1000'
SQL Server Error: 0
[Microsoft][ODBC SQL Server Driver]Cannot generate SSPI context

Almost there!
0
tusharkanvindeCommented:
Maybe you should change the zone to also include SQL Server Experts.

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

AndrewJenCommented:
0
pcelbaCommented:
I've never used AttachDbFilename=c:\spain.mdf in connection to SQL Server.

Following connection strings work for me:

SQLSTRINGCONNECT("Driver={SQL Server};database=spain;server=ComputerName\SQLServerInstanceName;uid=username;pwd=password")
SQLSTRINGCONNECT("Driver={SQL Server};database=spain;server=ComputerName\SQLServerInstanceName;trusted_connection=Yes")

You could also try to create DSN (in Control panel - Administrative Tools - ODBC data sources  or  Control panel - Additional Options - ODBC). DSN will allow to select available SQL server and test the connection before its first use, it will also allow to select the best connection and authentication methods.

If you create DSN then you may use SQLCONNECT() to establish the connection and select defined DSN from the dialog.

Other connection string examples are here: http://www.connectionstrings.com/
0
pcelbaCommented:
Also some hints how to solve "Cannot generate SSPI context" error are here:  http://support.microsoft.com/kb/811889/en-us/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fmoore0001Author Commented:
Thanks for the help, guys.  I was able to get in.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FoxPro

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.