Ajax + webserver and dataset to XML operation instance

Source: Internet
Author: User

A program code writes it to a blog
Front-end
<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %>
<HTML> WebService. asmx
<% @ WebService Language = "C #" codebehind = "~ /App_code/WebService. cs "class =" WebService "%>
 
WebService. CS
Using system; using system. web; using system. collections; using system. web. services; using system. web. services. protocols; using system. data; using system. data. sqlclient; using system. XML;
/// <Summary> /// Summary of WebService /// </Summary> [WebService (namespace = "http://tempuri.org/")] [webservicebinding (conformsto = wsiprofiles. basicprofile1_1)] public class WebService: system. web. services. webService {
Public WebService (){
// If the designed component is used, uncomment the following line // initializecomponent ();}
[Webmethod] Public String helloworld () {string conn = "Server = 127.0.0.1; database = temp; min pool size = 40; user id = sa; Password = sa123 "; sqlconnection myconn = new sqlconnection (conn); myconn. open (); string cmd = "select * from [user] Order by id desc"; sqldataadapter myread = new sqldataadapter (CMD, myconn); dataset myset = new dataset (); myread. fill (myset, "user"); myconn. close (); Return myset. getxml ();}}

 

Database Name temp
If exists (select * From DBO. sysobjects where id = object_id (n' [DBO]. [user] ') and objectproperty (ID, n' isusertable') = 1) Drop table [DBO]. [user] Go
Create Table [DBO]. [user] ([ID] [int] identity (1, 1) not null, [name] [nvarchar] (50) Collate chinese_prc_ci_as not null) on [primary] Go

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/sendling/archive/2008/10/20/3107647.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.