C # database operations through XML with Flash ActionScript 2.0 (I)

Source: Internet
Author: User
C # page
Output an XML document to read XML values in as to form a list.

Sing system;
Using system. collections;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. Web;
Using system. Web. sessionstate;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. htmlcontrols;
Using system. Text. regularexpressions;
Using system. text;
Using operclass;
Using system. xml;
Namespace wqwj. flashuser
{
/// <Summary>
/// Summary of flashmessagelist. Retrieve the XML short message list
/// </Summary>
Public class flashmessagelist: system. Web. UI. Page
{
Commclass cc = new commclass ();
String userid = "";
Private void page_load (Object sender, system. eventargs E)
{
// Place the user hereCodeTo initialize the page
// Creategrid ();
Showxml ();
}

# Region output XML
/// <Summary>
/// Retrieve data and export XML
/// </Summary>
Public void showxml ()
{Userid = request. querystring ["uid"]. tostring (); // "7 ";
String sqlstr = "select top 10 * From message where receiverid = '" + userid + "' and type = 0 and (delstate = '00' or delstate = '10 ') order by id desc ";
Dataset DS = cc. getds (sqlstr, "message ");
Xmldocument xmldoc = new xmldocument (); // Add the Declaration section of XML
String xml = "<? XML version = \ "1.0 \" encoding = \ "gb2312 \"?> <List> </List> ";
Xmldoc. loadxml (XML); // Add a declaration and a root element
If (Ds. Tables [0]. Rows. Count> 0)
{
For (INT I = 0; I <Ds. Tables [0]. Rows. Count; I ++)
{
String g_id = Ds. Tables [0]. Rows [I] ["ID"]. tostring (). Trim ();
String isread = Ds. Tables [0]. Rows [I] ["isread"]. tostring (). Trim ();
String ishf = Ds. Tables [0]. Rows [I] ["ishf"]. tostring (). Trim ();
String title = commclass. strdecode (Ds. Tables [0]. Rows [I] ["title"]. tostring (). Trim ());
String content = commclass. strdecode (Ds. Tables [0]. Rows [I] ["content"]. tostring (). Trim ());
String addtime = commclass. interceptstr (Ds. Tables [0]. Rows [I] ["addtime"]. tostring (), 0, 10, false );
String uid = Ds. Tables [0]. Rows [I] ["senderid"]. tostring (). Trim ();
String nickname = cc. getdataone ("select nickname from users where blocknumber =" + uid + "");

Xmlelement xmlelem = xmldoc. createelement ("messages"); // create an element

Xmlelem. setattribute ("m_id", g_id );
Xmlelem. setattribute ("m_uid", UID );
Xmlelem. setattribute ("m_title", title );
Xmlelem. setattribute ("m_nc", nickname );
Xmlelem. setattribute ("m_content", content );
Xmlelem. setattribute ("m_addtime", addtime );

Xmldoc. documentelement. appendchild (xmlelem); // Add the element to the <list> </List> flag.
}
}
Response. Write (xmldoc. innerxml );
}
# Endregion
# Code generated by region web Form Designer
Override protected void oninit (eventargs E)
{
//
// Codegen: This call is required by the ASP. NET web form designer.
//
Initializecomponent ();
Base. oninit (E );
}

/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void initializecomponent ()
{
This. Load + = new system. eventhandler (this. page_load );
}
# Endregion
}
}
Source code download

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.