G
Guest
I am writing my first database application. I am unable to even get to first
base because I can't seem to access the data in the database. Each time the
"Fill" command is executed I get an exception ["An error has occurred while
establishing a connection to the server. When connecting to SQL Server 2005,
this failure may be caused by the fact that under the default settings SQL
Server does not allow remote connections. (provider: Named Pipes Provider,
error: 40 - Could not open a connection to SQL Server)"]. Does anyone know
why this may be? The database has only two small tables and I am just trying
to access the first table. I have already enabled Remote connections on my
system.
private void GetData()
{
// Specify a connection string.
string connectionString = "Integrated Security=SSPI;Initial
Catalog=ClassData;Data Source=localhost";
SqlConnection connection = new SqlConnection(connectionString);
// Create a DataSet.
DataSet data = new DataSet();
data.Locale = System.Globalization.CultureInfo.InvariantCulture;
// Add data from the Customers table to the DataSet.
SqlDataAdapter masterDataAdapter = new SqlDataAdapter("select * from
Concepts", connection);
masterDataAdapter.Fill(data, "Concepts");
}
base because I can't seem to access the data in the database. Each time the
"Fill" command is executed I get an exception ["An error has occurred while
establishing a connection to the server. When connecting to SQL Server 2005,
this failure may be caused by the fact that under the default settings SQL
Server does not allow remote connections. (provider: Named Pipes Provider,
error: 40 - Could not open a connection to SQL Server)"]. Does anyone know
why this may be? The database has only two small tables and I am just trying
to access the first table. I have already enabled Remote connections on my
system.
private void GetData()
{
// Specify a connection string.
string connectionString = "Integrated Security=SSPI;Initial
Catalog=ClassData;Data Source=localhost";
SqlConnection connection = new SqlConnection(connectionString);
// Create a DataSet.
DataSet data = new DataSet();
data.Locale = System.Globalization.CultureInfo.InvariantCulture;
// Add data from the Customers table to the DataSet.
SqlDataAdapter masterDataAdapter = new SqlDataAdapter("select * from
Concepts", connection);
masterDataAdapter.Fill(data, "Concepts");
}