SqlWindows 6.1 OLEDB to SqlServer

General discussion forum about all databases other than SqlBase.
rleffew

SqlWindows 6.1 OLEDB to SqlServer

Post by rleffew » 29 Nov 2012, 13:56

I have installed SqlWindows 6.1 SP2 on Windows 7. I have SS 2008RE2 on my local machine. Trying to connect using OLEDB.

I have created a UDL file, contents of which are:

[oledb]
; Everything after this line is an OLE DB initstring
Provider=SQLOLEDB.1;Password=123456;Persist Security Info=True;User ID=sa;Initial Catalog=SRDB;Data Source=GCRDEV-7PRO\SRHOMES

Two code snippets:

Code: Select all

Set SqlUDL = 'test.udl'
If SqlConnect(hSql)
   Call SalMessageBox('OK','Connected',  MB_Ok)
This one connects -- it works!

However, what I would like to do is put all of that in the code, so this snippet:

Code: Select all

Set SqlUDL = 'Provider=SQLOLEDB.1;Password=123456;Persist Security Info=True;User ID=sa;Initial Catalog=SRDB;Data Source=GCRDEV-7PRO\SRHOMES'
If SqlConnect(hSql)
   Call SalMessageBox('OK','Connected',  MB_Ok)
Else
   Call SalMessageBox('Bummer','ERROR', MB_Ok)
Does NOT work -- it returns: SQL Error: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

I'm probably doing something stupid, any advise is appreciated.

Thanks,

Roy.

UVS

Re: SqlWindows 6.1 OLEDB to SqlServer

Post by UVS » 04 Dec 2012, 20:37

I use:
Set SqlUDL = 'Provider=SQLOLEDB;Data Source=' || strGlobalLocalServer || ';Initial Catalog=' || strServerName || ';Integrated Security=SSPI'

Works fine for me. Also take a look at the string after you have created it and make sure it reads correctly.

User avatar
markus.essmayr
Site Admin
Site Admin
Austria
Posts: 892
Joined: 06 Mar 2017, 06:07
Location: Austria

Re: SqlWindows 6.1 OLEDB to SqlServer

Post by markus.essmayr » 05 Dec 2012, 07:49

Hello,

your connection string contins a backslash character in the data source: "GCRDEV-7PRO\SRHOMES"
Ensure that you quote that: "GCRDEV-7PRO\\SRHOMES"

Max
Markus Eßmayr
teamdeveloper@t-mx.com

rleffew

Re: SqlWindows 6.1 OLEDB to SqlServer

Post by rleffew » 05 Dec 2012, 13:52

Thanks Max!

I knew I had to be doing something "stupid". Trying to save time in testing, I keyed in the whole string forgetting about the special character backslash! :oops:

Roy.

User avatar
markus.essmayr
Site Admin
Site Admin
Austria
Posts: 892
Joined: 06 Mar 2017, 06:07
Location: Austria

Re: SqlWindows 6.1 OLEDB to SqlServer

Post by markus.essmayr » 06 Dec 2012, 13:01

No problem!
I think that already happened to everybody of us.
Sometimes it just need's another pair of eyes to "see"! :)

Max
Markus Eßmayr
teamdeveloper@t-mx.com

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests