Page 1 of 1

SqlWindows 6.1 OLEDB to SqlServer

PostPosted: Thu Nov 29, 2012 5:56 am
by rleffew
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.

Re: SqlWindows 6.1 OLEDB to SqlServer

PostPosted: Tue Dec 04, 2012 12:37 pm
by UVS
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.

Re: SqlWindows 6.1 OLEDB to SqlServer

PostPosted: Tue Dec 04, 2012 11:49 pm
by lrcuess
Hello,

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

Max

Re: SqlWindows 6.1 OLEDB to SqlServer

PostPosted: Wed Dec 05, 2012 5:52 am
by rleffew
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.

Re: SqlWindows 6.1 OLEDB to SqlServer

PostPosted: Thu Dec 06, 2012 5:01 am
by lrcuess
No problem!
I think that already happened to everybody of us.
Sometimes it just need's another pair of eyes to "see"! :)

Max