Send a Dataset as a Dime Attachment
Hello,
Thanks very much for posting here.
After reviewing the question, I think you could just return dataset in the web method and then use it in your windows forms
client as the datasource. Dataset uses XML to store data internally and so it can be returned in webmethod in web service.
For an example:
[WebMethod]
public DataSet GetCustomers()
{
SqlConnection con = new SqlConnection("server=servername;uid=login;
pwd=password;database=northwind");
SqlDataAdapter daCust = new SqlDataAdapter("Select * From Customers", con);
DataSet ds = new DataSet();
daCust.Fill(ds, "Cust");
return ds;
}
For details, please refer to MSDN article "HOW TO: Update Server Data Through a Web Service by Using ADO.NET and
Visual C# .NET" at http://support.microsoft.com/?id=310143.
Thansk.
Best regards,
Yanhong Huang
Microsoft Online Partner Support
Get Secure! - http://www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
!Reply-To: "hs" <hs@nospam.syn>
!From: "hs" <hs@nospam.syn>
!Subject: Send a Dataset as a Dime Attachment
!Date: Fri, 1 Aug 2003 16:11:24 +0100
!Lines: 36
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <#QAkv8DWDHA.2360@TK2MSFTNGP12.phx.gbl>
!Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
!NNTP-Posting-Host: mailgate.synergy-logistics.co.uk 62.49.130.162
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webservic es:18583
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
!
!Hi
!I looked in the archives and modified a webmethod example by Roman Kiss to
!give
!
![WebMethod]
!public string DownloadUsingDime()
!{
!
! // Create a new Dime Attachment class
! OleDbConnection dbconn = new OleDbConnection("Provider=MSDAORA.1;Data
!Source=Test");
! OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Product",
!dbconn);
! DataSet ds = new DataSet();
! da.Fill(ds);
!
! MemoryStream ms = new MemoryStream();
! ds.WriteXml(ms);
!
! // attach body
! DimeAttachment attachment = new
!DimeAttachment("application/octet-stream", TypeFormatEnum.MediaType, ms);
! HttpSoapContext.ResponseContext.Attachments.Clear( );
! HttpSoapContext.ResponseContext.Attachments.Add(at tachment);
! return "Dime Test";
!}
!
!How can I send the dataset object as the dime attachment, as opposed to a
!Stream made up of the dataset's contents.
!
!My aim is to make the dataset object the datasource for a winform client
!datagrid.
!
!thanks
!
!
!
|