473,386 Members | 1,943 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,386 software developers and data experts.

Web Service Error

I'm trying to get a web service (with C#) to access a remote database, and provide a connection between the data (MS Access .mdb database) and a Windows client. At present I am running it all on localhost. However, I receive the error:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: The ConnectionString property has not been initialised.
at Ststem.Data.OleDb.OleDbConnection.Open()
at .....

What could the problem be?

I have two web methods called consecutively, as follows:

[WebMethod]
public void SupplyDatabasePassword(string Password) {
Password.Trim(); Password.ToLower(); if (Password.LastIndexOf(';') > -1) return;
this.oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Jet OLEDB:Database Password=" + Password + @"; Data source=" + Server.MapPath("TMIData.mdb") +@"; User ID=Admin; Password=; Persist Security Info=true";
}

[WebMethod]
public bool VerifyDBAccess() {
//try {
oleDbConnection1.Open();
return true;
//} catch {
// return false;
//};
}

First, my Windows application specifies the password, and then it verifies the database by attempting to open it.

Do I have to set the connectionstring and open in the same method? If so, is there a way around this?

Please help, and thanks in advance!

James
Nov 12 '05 #1
1 2783
Em... webservices (as well as ASP.NET and almost everything
internet-related) is stateless. Therefore, when you set the connection
string in the first method, you're not persisting it for the second method
call. You should do both things at the same time. The webservice class is
created and discarded at each request. It's a completely new instance each
time. Don't store things in fields, it's useless.

HTH
Cheers,

--
Daniel Cazzulino [XML MVP]
Lagash Systems SA
http://weblogs.asp.net/cazzu
"James" <ja*********@hotmail.com> wrote in message
news:80**********************************@microsof t.com...
I'm trying to get a web service (with C#) to access a remote database, and provide a connection between the data (MS Access .mdb database) and a
Windows client. At present I am running it all on localhost. However, I
receive the error:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: The ConnectionString
property has not been initialised. at Ststem.Data.OleDb.OleDbConnection.Open()
at .....

What could the problem be?

I have two web methods called consecutively, as follows:

[WebMethod]
public void SupplyDatabasePassword(string Password) {
Password.Trim(); Password.ToLower(); if (Password.LastIndexOf(';') > -1) return; this.oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Jet OLEDB:Database Password=" + Password
+ @"; Data source=" + Server.MapPath("TMIData.mdb") +@"; User ID=Admin;
Password=; Persist Security Info=true"; }

[WebMethod]
public bool VerifyDBAccess() {
//try {
oleDbConnection1.Open();
return true;
//} catch {
// return false;
//};
}

First, my Windows application specifies the password, and then it verifies the database by attempting to open it.
Do I have to set the connectionstring and open in the same method? If so, is there a way around this?
Please help, and thanks in advance!

James

Nov 12 '05 #2

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

Similar topics

3
by: David Fraser | last post by:
Hi We are trying to debug a problem with services created using py2exe. It seems that these problems have arisen after services were installed and removed a few times. OK, first the actual...
18
by: jabailo | last post by:
I wrote a program that loops through a file of records. It parses each line in the file and sends them to a web service that inserts them into an AS400DB2 database using Asynch calls. This is...
9
by: Hardy Wang | last post by:
Hi all: I read an article from http://www.c-sharpcorner.com/Code/2003/Sept/InstallingWinServiceProgrammatically.asp about how to install a windows service programmatically. Based ont the code...
4
by: Keith | last post by:
I'm in the same boat as the fellow who posted this message back in August: Title : Windows Service, How does one make a service "fail" properly? Author : Ross Bennett Group :...
5
by: John | last post by:
Hi I am trying to get web reference to my first (!) web service which is on a remote host. I am getting the following error; Server Error in '/' Application. Runtime Error Description: An...
2
by: timsohn | last post by:
I am trying to deploy the most basic web service (Hello World) example to my website, but am having significant trouble doing so. Here is what I am doing: 1) Create a New Web Service in VS 2005...
4
by: jf li | last post by:
I have a Asp.net web application and a Asp.net Web service application. The Web application is using HtmlInputFile to get a 50M size of file selected by end user, read the data of this file and...
4
by: Jason Richmeier | last post by:
I am sure this has been asked at least once before but I could not find anything when searching. If I set the value of the ExitCode property to 1066 for a windows service, the text "A service...
0
by: Jeova Almeida | last post by:
Hello, I created a simple web service for testing purpose in Visual Studio 2005: <%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" Class="WSTest" %> using System;
0
by: Jeova Almeida | last post by:
Hello, I created a simple web service for testing purpose in Visual Studio 2005: <%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" Class="WSTest" %> using System;
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.