I tried the Mono-SLED VMWare image from Novell.
SLED stands for SuSe Linux Enterprise Desktop.
I wanted to try to see if I could connect to Microsoft SQL Server 2005 Express running on my Windows box from the SLED guest using a Mono application. So, I tried.
It failed -- at first.
To test to see if I could get it working on Linux, I tried first on Windows to see if I could connect via TCP/IP. On Windows, I copied sqlsharp.exe from my Mono installation bin path to somewhere outside of the mono installation. I then started a Microsoft .NET SDK Command Prompt. I started sqlsharp.exe
G:\>sqlsharp.exe
SQL# \provider sqlclient
The default Provider is SQLCLIENT
SQL# \connectionstring server=MYHOST\SQLEXPRESS;DATABASE=master;user id=sa;password=mypass
SQL# \open
Opening connection...
Open was successfull.
I tried the same using mono on Windows:
G:\>mono sqlsharp.exe
SQL# \open
Opening connection...
Exception Caught Opening. SQL Server does not exist or access denied.
Hmmm... How come Microsoft .NET works but Mono does not?
MSDN says dbmssocn (library which uses TCP/IP to connect to SQL Server) is the default library to use. However, I have proved this to be false.
Now, try this connection string in sqlharp on the .NET SDK. I explicitly set the network library to dbmssocn.
SQL# \connectionstring server=MYHOST\SQLEXPRESS;DATABASE=master;user id=sa;password=mypass;network library=dbmssocn
SQL# \open
Opening connection...
Exception Caught Opening. Specified SQL server not found: MYHOST\SQLEXPRESS
If you tried connecting via Mono and TCP is not enabled on SQL Server, you might have gotten:
SQL# \open
Opening connection...
Exception Caught Opening. Only TCP/IP is supported.
By default, SQL Server 2005 Express has TCP/IP disabled. So, you have to go into SQL Server Configuration Manager and enable TCP/IP for each instance you wish to connect via TCP/IP. But, you also must make sure the TCP/IP Protocol is one of the allowed client protocols. I also made sure my firewall allowed mono.exe and sqlsharp.exe to do networking. And I allowed the SQL Server Monitor UDP Port 1434 in my firewall. If this udp port is not enabled, then SqlClient running on Linux will not be able to get the TCP port to connect to based on the instance name SQLEXPRESS.
SQL Server 2005 Network Configuration
Protocols for SQLEXPRESS
enable TCP/IP
and
SQL Server Native Client
Client Protocols
enable TCP/IP
If SLED can't find your hostname, use the ipconfig command on Windows to get your IP Address. Ipconfig will list the IP address for your VMWare guest (SLED) as well.
Once this is done, you can connect to SQL Server 2005 from Mono running on SLED. A valid query to use is:
select * from sysdatabases;
Moreover, the Mono-SLED VMWare image provides a good way to test your .net apps to see if they will run on Mono on Linux. This is important if you want to develop applications that run on .net on windows and mono on linux on the same machine. Dual-boot will not work because SQL Server only runs on Windows.