By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,205 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,205 IT Pros & Developers. It's quick & easy.

Web Service Error

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.