Comments are available to members only. Sign up or Log in to view these comments.
Main Topics
Browse All TopicsHi Experts,
After days examining different ways to consume a ADO.NET dataset sent
by a webservice method, I found that article of DrBob (http://www.drbob42.com/ex
which gave the idea to use the ADONETConnector to take the data to ClientDataset and save it to a
XML string.
The code for the function is below:
function ObterXMLDataPacket(
pADONET_Dataset: DataSet; pNumero_DataTable: Integer): String;
var Conector:TADONETConnector;
Cds:TclientDataset;
DSP:TDatasetProvider;
St: TStringStream;
begin
If pADONET_Dataset.Tables.Cou
(*Cria os componentes necessários*)
Cds := TClientDataSet.Create(nil)
DSP := TDataSetProvider.Create(ni
St := TStringStream.Create;
Conector := TADONETConnector.Create(ni
(*Conecta os componentes*)
DSP.Dataset := Conector;
Cds.SetProvider(DSP);
Conector.DataTable := pADONET_Dataset.Tables[pNu
(*Obtém os dados*)
Conector.Open;
CDS.Open; // Here the method throws the exception
(*Transforma os dados em XML Datapacket*)
Cds.SaveToStream(St,dfXML)
Result := ST.DataString;
(*Limpa o ambientes*)
St.Free;
Cds.Free;
Conector.Free;
DSP.Free;
end;
The function is used in a WebMethod which opens a BDPDataAdapter and calls the function with the Dataset
populated by the Adapter.
Here is the code:
function TCC_DataLayer.RetornaDatas
begin
BdpDataAdapter1.Active := True;
Result := ObterXMLDataPacket(ds1,0);
end;
With the needed units (ADONetDb, System.Data, etc among a few other ones) - the WebService build without problems. But when the method is called, the execution is aborted with a exception (on the Win32 client, on the browser gave only a internal server error).
Here is the message of the Exception: "Servidor não pôde processar a solicitação. --> Invalid threading model (STAThreadAttribute is required)"
The first part is in Brazilian Portuguese and means: "Server could not process the request"
Here is the code where the WebMethod is called:
procedure TForm2.Button2Click(Sender
var Comm:THTTPRIO;
begin
Comm := THTTPRIO.Create(nil);
WServico := GetTCC_DataLayerSoap(False
try
ClientDataSet1.XMLData := WServico.RetornaDatasetXML
ClientDataSet1.Open;
except
on E: Exception do
begin
With TStringList.Create do
begin
Add(E.Message);
SaveToFile('c:\mensagemerr
Free;
end;
end;
end;
end;
Environment: Delphi 2006 Architect (Borland® Developer Studio for Microsoft® Windows™ Version 10.0.2288.42451 Update 2), IIS + ASP.NET 1.1.4322...
DataBase: MSSQL 2005 (just for the sake of completeness).
Best Regards and thank you very much for the attention,
Fabricio (Delphian)
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: Ivanov_GPosted on 2006-07-15 at 04:37:34ID: 17114029
Comments are available to members only. Sign up or Log in to view these comments.