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