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)

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


Attachments

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.

Note You need to log in before you can comment on or make changes to this bug.