Bug 33877 - SqlClient Count't Connection To SqlServer like this Connection string "Data source=52.74.251.3\SqlExpress2005,14433;"
Summary: SqlClient Count't Connection To SqlServer like this Connection string "Data s...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: 4.2.0 (C6)
Hardware: All Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-09-11 04:19 UTC by 175350486
Modified: 2018-02-22 22:32 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description 175350486 2015-09-11 04:19:15 UTC
BUG Report

Assemblies	:System.Data.SqlClient.SqlConnection
Method		:ParseDataSource()
BUG detail	:when connection string data source format like "Data source=52.74.251.34\SqlExpress2005,33433;" resolve error.

Error code	:
int idx = 0;
			
if ((idx = theDataSource.IndexOf (',')) > -1) 
{
				
	theServerName = theDataSource.Substring (0, idx);
				
	string p = theDataSource.Substring (idx + 1);
				
	thePort = Int32.Parse (p);
			
} 
else if ((idx = theDataSource.IndexOf ('\\')) > -1) 
{
				
	theServerName = theDataSource.Substring (0, idx);
				
	theInstanceName = theDataSource.Substring (idx + 1);

				
	// do port discovery via UDP port 1434
				
	port = DiscoverTcpPortViaSqlMonitor (theServerName, theInstanceName);
				
	if (port == -1)
					
		success = false;
			
} 
else
				
	theServerName = theDataSource;

Repair code	:

theServerName = theDataSource;
			
int idx = 0;
if ((idx = theServerName.IndexOf(',')) > -1)
{
	string p = theServerName.Substring(idx + 1);
	thePort = Int32.Parse(p);
	theServerName = theServerName.Substring(0, idx);
			
}
if ((idx = theServerName.IndexOf('\\')) > -1)
{
	theInstanceName = theDataSource.Substring(idx + 1);
	theServerName = theServerName.Substring(0, idx);
	if (thePort <= 0)
	{
		// do port discovery via UDP port 1434
		port = DiscoverTcpPortViaSqlMonitor(theServerName, theInstanceName);
		if (port == -1)
			success = false;
	}
			
}
Comment 1 Marek Safar 2018-02-22 22:32:14 UTC
Mono 5.10 has significantly improved System.Data implementation which should resolve this issue. If you can still reproduce it please reopen the issue.