[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webservices

RE: Send a Dataset as a Dime Attachment

yhhuang

8/5/2003 2:54:00 AM

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/....

Thansk.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - 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.webservices
!NNTP-Posting-Host: mailgate.synergy-logistics.co.uk 62.49.130.162
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webservices:18583
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
!
!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(attachment);
! 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
!
!
!


2 Answers

hs

8/5/2003 7:15:00 AM

0

Thanks YanHong.
I am actually carrying out some tests comparing a webmethod, like the one
you have shown and alternatively, sending a dataset as an attachement. Any
way I found the answer to my original question.
Datasets are serializable, so i just just serialize it before attaching it
to dime.




"Yan-Hong Huang[MSFT]" <yhhuang@online.microsoft.com> wrote in message
news:NtWMVzvWDHA.1544@cpmsftngxa06.phx.gbl...
> 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/....
>
> Thansk.
>
> Best regards,
> Yanhong Huang
> Microsoft Online Partner Support
>
> Get Secure! - 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.webservices
> !NNTP-Posting-Host: mailgate.synergy-logistics.co.uk 62.49.130.162
> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
> !Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:18583
> !X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
> !
> !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(attachment);
> ! 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
> !
> !
> !
>
>


Daniel Johansson

8/16/2003 12:13:00 PM

0

Hi

I have the same problem but I can´t access the
Microsoft.Web.Services.Dime - namespace.
How do I fetch that dll and what changes in .NET
do I have to do?

Regards

// Daniel
"Yan-Hong Huang[MSFT]" <yhhuang@online.microsoft.com> skrev i meddelandet
news:NtWMVzvWDHA.1544@cpmsftngxa06.phx.gbl...
> 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/....
>
> Thansk.
>
> Best regards,
> Yanhong Huang
> Microsoft Online Partner Support
>
> Get Secure! - 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.webservices
> !NNTP-Posting-Host: mailgate.synergy-logistics.co.uk 62.49.130.162
> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
> !Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:18583
> !X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
> !
> !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(attachment);
> ! 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
> !
> !
> !
>
>