Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AV's and Parameters not found...
#1
Hi All,

Again I have a multiuser issue. This time it is in a Web service, wrapped in a TService Shell, and installed as a HTTP.SYS program on a server.

The problems show-up when more than one client at a time, and ONLY when more than one client, do the same operations. 

The client is a Windows 32 program, running on individual users PC's all within the Company domain, accessing data in a SQL table on a MS SQL server, also within the Company domain. There are several webservice calls in one operation, to read or write various data from and to the SQL table.

As there are no ServerController unit (or UserSession unit) I have not been able to set the "ComInitialization" property, nor am I calling CoInitialize and CoUnInitialize anywhere in the Win32 program, or in the Webservice. Could that be the reason, and if, how do I correct it ?

Also, trying to add CoInitialize and CoUnInitialize as calls in the Win32 program, before and after each Webservice call, I can't compile the program. Compiler says "Undeclared identifier". Which unit are the co-calls defined in ?

I hope someone can help. As it is now, these problems are showstoppers.

Regards
Soren
Reply
#2
I am a bit closer to finding the reason, I hope. Tests today gives ADOStoredProc error: Cannot persorm this operation on a closed dataset.

However, the dataset is not closed at the time of the call. I always use a structure like this:

dm := TApp3TDB.Create(nil);
try
dm.ADOSP1.ProcedureName := 'sp_CustomerGet';
dm.ADOSP1.Parameters.Refresh;
dm.ADOSP1.Parameters.ParamByName('@CustomerNo').value := CustomerNo;
dm.ADOSP1.Prepared := true;
try
dm.ADOSP1.open;
if dm.ADOSP1.RecordCount > 0 then
begin
CustomerName := dm.ADOSP1.FieldByName('CustomerName').AsString;
end;
except
on e:exception do LogError('Error: '+e.Message);
end;
finally
dm.Free;
end;

So I do open it (or when calling a sp with and update/insert or Delete statement, I use ADOSP1.ExceSql).

What I do not do, is close it, so the error should be Dataset NOT closed rather than Dataset closed. As the procedure exits after, I expect ADOSP1 will be closed without specifically having the code to call adosp1.close;

If could be the properties of the ADOSP1, I need to set differently, but I do not know enough about which or why, so if anybody knows abut these, please feel free to comment.

Regards
Soren

NB! I do still think it is a question of sharing conflicts, like in a non thread safe code.
Reply
#3
Hi Guys,

A solution has been found. And the solution lies in line with a similar problem I had with an IW application and thread safe / session safe variables.

For the Web service it turns out to be the same rules that govern safety. All vars outside the web service Class definition, and its corresponding end, is not safe.

Having a datamodule with the ADO components on, I define the DM for the Web Service IMPL file, as dm : TApp2TBD; and in each procedure where I call a WS function or procedure, I create the DM with dm := TApp3TDB.Create(nil); just before the lines setting the ADO components up. And it's all wrapped in a try-final-end so the DM if Free'd up after use.

The problem was that the dm def "dm : TApp2TBD;" was outside the WebService Class / End definitions. IOnce I moved it to the private section, the problems dissapered.

Regards
Soren
Reply
#4
Awesome! Thanks for the follow up. Yes, threads are threads.. so same rules apply.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)