Connect with IP Address to MS SQL Express

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mfbrowne
Posts: 13
Joined: Mon 15 Nov 2010 00:17

Connect with IP Address to MS SQL Express

Post by mfbrowne » Mon 12 May 2014 14:03

Hello,

Have used the uni connection to connect to a MySql Database using an IP Address, however when I try and connect a MS SQL Express database using an ip address and the connection fails. I have connected using NAMEOFCOMPUTER\SQL2012EXPRESS.

So could someone tell me what I need to do using the uni connection and an IP Address to the SQL Express database.

Thank you very much.

Mike

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Connect with IP Address to MS SQL Express

Post by azyk » Thu 15 May 2014 10:55

Hi,

You can use <ip address>\<instance name> instead of <host name>\<instance name>. If you want to use only <ip address>, you should set up Default Instance on the MS SQL Server.
You can find more details in MSDN documentation.

mfbrowne
Posts: 13
Joined: Mon 15 Nov 2010 00:17

Re: Connect with IP Address to MS SQL Express

Post by mfbrowne » Thu 15 May 2014 13:00

Hello,

Ok I understand what you have said. However right now when I connect I was using the uniconnection control in the ide by double clicking on it and getting the connection dialog. But now when I try and use the uniconnection in program code by filling in the required info I am getting the following error:

SQL Server provider is not registered. You should add the SQLServerUniProvider unit to the uses clause of any unit in your project or place the TSQLServerUniProvider component on the form.

I have the TSQLServerUniProvider on the form and I also have the msprovider140.lib linked to the unit. So I do not understand why this error would be occurring.

I enter the following into the uniconnection Control:

HdbcDB = new TUniConnection(NULL) ;
HdbcDB>LoginPrompt = false ;
HdbcDB->ProviderName = "SQL Server" ;
HdbcDB->Server = "NameOfComputer\SQL2012Express" ;
HdbcDB->Username ="UserId" ;
HdbcDB->Password = "Password" ;
HdbcDB->Database = "databaseName" ;

I get the above error as soon as I try and issue the connection to the database.

Could someone please help me in this as I am being pressed to have a solution quickly.

Thank you

Mike

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Connect with IP Address to MS SQL Express

Post by azyk » Fri 16 May 2014 09:49

Hello,

Thank you for the information. To avoid this error for C++Builder 2010, you should open the SQLServerUniProvider.hpp file located in "C:\Program Files\Devart\UniDAC for RAD Studio 2010\Include\" - and replace the line

#pragma comment(lib, "msprovider140")
with
#pragma comment(lib, "msprovider140.bpi")

myler
Posts: 1
Joined: Tue 22 Oct 2013 10:06

Re: Connect with IP Address to MS SQL Express

Post by myler » Sat 20 Sep 2014 17:50

Hello guys, I've just installed C++ Builder XE7.
I found the same issue: I get the suggestion to open SQLServerUniProvider.
Unfortunaly the include file "SQLServerUniProvider.hpp" do not need to be fixed.

The problem arises when the DAC components are instanciated directly in the code. If they are dropped on the form... they work fine.
At the moment I found this workaround to the problem: I went into the project options (Packages|Runtime Packages), I unchecked the option "link with runtime packages".

This has been enough to connect the SQLServer database without issues.
In SQLServerUniProvider.hpp I saw:
#ifdef USEPACKAGES
...
#else
#pragma comment (lib, "msprovider210.lib")
#endif
so I tried to compile the program with the library and it worked fine!
I hope to find also the way in order to use runtime packages, of course.

Post Reply