View Single Post
  #6 (permalink)  
Old December 1st, 2014, 06:19 PM
C#Learner C#Learner is offline
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2014
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If I start the program and try to select server (File-Select server) in 10 or so seconds I can see cmbServer with the only name, which is the name of my computer (Toshiba). Actual SQL Server name is: Toshiba\SQLEXPRESS.

Of course if I select it I have an error window with the message:
=================================================
Error occurred while reading database data: A network-related or instance-specific error occurred while establishing a connection to SQL Server.
The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connection. (provider: Named Pipes Provider, error: 40-Could not open a connection to SQL Server.)
=================================================

After I close window (named: Select server and Database) this line:

this.mdiParent.getDatabaseName = cmbDatabase.SelectedItem.ToString();

in frmServerSelect throws an exception:
=================================================

Microsoft Visual Studio Express 2013 for Windows Desktop

An unhandled exception of type 'System.NullReferenceException' occurred in Ch14CreateDatabase.exe

Additional information: Object reference not set to an instance of an object.
=================================================

If I hardcode I can establish the connection with database.

Console application only proofs that SqlDataSourceEnumerator Class does not work properly on my computer.
=================================================

using System.Data;

using System.Data.Sql;

using System;

public class ListSqlInstances
{

public static int Main(string[] args)
{

SqlDataSourceEnumerator sqldatasourceenumerator1 = SqlDataSourceEnumerator.Instance;

DataTable datatable1 = sqldatasourceenumerator1.GetDataSources();

foreach (DataRow row in datatable1.Rows)
{

Console.WriteLine("******************************* *********");

Console.WriteLine("Server Name:" + row["ServerName"]);

Console.WriteLine("Instance Name:" + row["InstanceName"]);

Console.WriteLine("Is Clustered:" + row["IsClustered"]);

Console.WriteLine("Version:" + row["Version"]);

Console.WriteLine("******************************* *********");

}
Console.ReadLine();
return 1;
}
}
=================================================

The result is:
================================
Server Name:Toshiba
Instance Name:
Is Clustered:
Version:
================================

What should I do to get it working?
I really appreciate your help.

Best regards.