Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Remind me, please SQL connection
Message
From
04/01/2019 12:41:13
 
 
To
04/01/2019 12:37:03
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows Server 2016
Miscellaneous
Thread ID:
01665115
Message ID:
01665137
Views:
46
>>>>It's been awhile and I'm trying to connect to a MSSQL server with the following
>>>>
>>>>myconnstr = "driver = SQL Server; server=IPaddress; database=myDB; uid=myID; pwd=myPassword"
>>>>
>>>>when I issue the myconnection = SQLStringConnect(myconnstr) it keeps popping up asking me to select a DNS.
>>>>
>>>>What am I forgetting?
>>>>tia
>>>
>>>
>>>Driver={SQL Server Native Client 11.0};server=<IPAddress or just a dot for local machine>[, <port if not default>]\instanceName;database=myDb;Trusted_Connection=yes;
>>>
>>>
>>>{SQL Server} is the old 2000 driver, prefer newer ones like {SQL Server Native Client 11.0}.
>>>
>>>A typical connection to local SQLExpress instance Northwind database:
>>>
>>>
>>>Driver={SQL Server Native Client 11.0};server=.\SQLExpress;database=Northwind;Trusted_Connection=yes;
>>>
>>
>>Thanks for that information, Cetin.
>>
>>Making those changes and trying the SQLStringConnect, it still asks for a DSN. It was my remembering that SQLStringConnect would connect without a DSN, nor would it require one. Am I mis-remembering?
>
>No you remember right. It wouldn't ask for a DNS (I never use one). That message means you are mistyping something (spaces around = for example, remove them. Or non existent server ...).
>
>
>This example is a working code from my backyard:
>
>
>local lcSQL
>TEXT TO m.lcSQL NOSHOW TEXTMERGE
>SELECT * 
>FROM Customers AS c
>WHERE c.Country = ?m.lcCountry;
>ENDTEXT
>
>
>
>Close Databases all
>strCon = "Driver={Sql server native client 11.0};Server=.\SQLExpress2012;Database=Northwind;Trusted_Connection=yes"
>
>handle = SQLStringConnect( m.strCon )
>? m.handle
>
>SQLPrepare(m.handle, m.lcSQL, 'ccc')
>
>Local array laCountries[5]
>laCountries[1] = 'USA'
>laCountries[2] = 'UK'
>laCountries[3] = 'Germany'
>laCountries[4] = 'Argentina'
>laCountries[5] = 'Mexico'
>
>For ix = 1 to 5
>    lcCountry = laCountries[m.ix]
>	SQLExec(m.handle)
>	Select ccc
>	Browse 
>EndFor
>
>SQLDisconnect(0)
>
HUZZAH!!! It worked!

Dang me for wanting clearly readable command lines :-)

Thanks again, Cetin
"You don't manage people. You manage things - people you lead" Adm. Grace Hopper
Pflugerville, between a Rock and a Weird Place
Previous
Reply
Map
View

Click here to load this message in the networking platform