473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Exception error generated when accessing Access database

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");
}

--
-----------
Thanks,
Steve
Apr 10 '06 #1
3 2451
Hi Steve,

As far as I know, SQL server 2005 does not allow remote connections by
default. You can try to enable it through the following steps:

1. Start -> Programs -> Microsoft SQL Server 2005 -> Configuration Tools ->
SQL Server 2005 Surface Area Configuration.
2. Click Surface Area Configuration for Services and Connections.
3. In the left treeview, navigate to (Instance)/Database Engine/Remote
Connections.
4. In the right pane, select Local and remote connections, and enable
TCP/IP or named pipes according to your requirements.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Apr 10 '06 #2
> 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");
}


You are trying to use an Access database? Then you should not use the
SqlConnection and other Sql* objects, as they are specifically for
SqlServer.
You need to use OleDbConnection and it's friends from the
System.Data.OleDb namespace.
The connection string would be something like
"Provider=Microsoft.Jet.OLEDB.4.0; data source={full filename};
user id={loginname}; password={password};"

where the {} parts are replaced (including the {} ) by the correct
values.

Hans Kesting
Apr 10 '06 #3
Thank you very much. This was indeed the solution to my problem.
--
-----------
Thanks,
Steve
"Hans Kesting" wrote:
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");
}


You are trying to use an Access database? Then you should not use the
SqlConnection and other Sql* objects, as they are specifically for
SqlServer.
You need to use OleDbConnection and it's friends from the
System.Data.OleDb namespace.
The connection string would be something like
"Provider=Microsoft.Jet.OLEDB.4.0; data source={full filename};
user id={loginname}; password={password};"

where the {} parts are replaced (including the {} ) by the correct
values.

Hans Kesting

Apr 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
4
by: Charlie Williams | last post by:
I am having difficulty performing updates and deletions on an Access database using the Update() method of the OleDBDataAdapter. I can insert rows without a problem, but I get a concurrency...
7
by: Abdul-Wahid Paterson | last post by:
Hi, I have had a site working for the last 2 years and have had no problems until at the weekend I replace my database server with a newer one. The database migration went like a dream and I had...
4
by: maricel | last post by:
I have the following base table structure - DDL: CREATE TABLE "ADMINISTRATOR"."T1" ( "C1" INTEGER NOT NULL ) IN "TEST_TS" ; ALTER TABLE "ADMINISTRATOR"."T1" ADD PRIMARY KEY
5
by: Santiago Ordax Solivellas | last post by:
Hi. We have almost all our tables defined on library lib1 and some on lib2. We have alias defined on lib1 to access tables on lib2 so there is no need to qualify library name. Alias for tables on...
5
by: Philippa | last post by:
I'm trying to access data in vba using the openrecordset command. The data in on a SQL Server 2000 database, and I have linked tables to that data. the Table I'm trying to access is one of these...
7
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
3
by: ajl | last post by:
I am getting following error on accessing a asp.net application from virtual directory /website. Please suggest me the solution. Server Error in '/website' Application....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.