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: NEW
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: 2017-09-01 09:30 UTC (History)
1 user (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;
	}
			
}

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