小编tim*_*ack的帖子

如何将数据插入asp.net中的现有xml文件?

我正在使用Visual Web Developer 2008 Express Edition,因为我是新手,所以我需要你的帮助.我正在尝试将数据插入或写入我的xml文件,以便我可以将其显示到我的xml控件中.现在,我在这里尝试做的是每当用户在文本框中输入一条消息时,他都可以保存它,所以如果他点击命令按钮我想将文本消息从文本框保存到我的xml的任何元素中文件.比方说,我想将它插入我的xml文件的元素中.如何使用C#或VB.Net代码执行此操作?我有下面的xml文件和我的C#代码,但c#代码对我不起作用.我需要c#或vb.net中的代码,无论哪种方式都适合我.非常感谢,非常感谢任何可以分享的帮助.

myxmlfile.xml

<?xml version="1.0" encoding="utf-8" ?>
<comments>
    <comment>
        Your Comments Here: Please post your comments now. Thank you. 
    </comment>
    <comment2>
        Note: Please do not post any profane languages.
    </comment2>
    <comment3>
        I don't like their service. It's too lousy.
    </comment3>
    <comment4>
        Always be alert on your duty. Don't be tardy enough to waste your time.
    </comment4>
</comments>
Run Code Online (Sandbox Code Playgroud)

protected void Button1_Click(object sender, EventArgs e)
{
    System.Xml.Linq.XDocument mydoc = 
        new System.Xml.Linq.XDocument(
            new System.Xml.Linq.XDeclaration("1.0", "UTF-8", "yes"),
            new System.Xml.Linq.XElement("comment", …
Run Code Online (Sandbox Code Playgroud)

c# xml asp.net

5
推荐指数
1
解决办法
2万
查看次数

如何根据选定的行获取上一行和下一行?

我正在尝试获取确切的T-SQL语句来获取所选行的上一行和下一行.这是下面给出的表格.

表名:MyExTab

ID      Name     Address       Age    Nationality
------  -------  -----------   -----  -----------
1160    Kate     New Jersey    28     American
1161    Kelly    Connecticut   32     American
1162    Jenny    New York      30     American
1163    Heather  New York      29     American
1164    Ashley   Pennsylvania  29     American
Run Code Online (Sandbox Code Playgroud)

如果我想使用表示行的ID = 1162查询行

ID      Name     Address       Age    Nationality
------  -------  -----------   -----  -----------
1162    Jenny    New York      30     American
Run Code Online (Sandbox Code Playgroud)

它应该只返回基于所选行ID的上一行和下一行的两行,如下所示.

ID      Name     Address       Age    Nationality
------  -------  -----------   -----  -----------
1161    Kelly    Connecticut   32     American …
Run Code Online (Sandbox Code Playgroud)

t-sql sql-server asp.net-mvc-4 sql-server-2012

1
推荐指数
1
解决办法
161
查看次数

标签 统计

asp.net ×1

asp.net-mvc-4 ×1

c# ×1

sql-server ×1

sql-server-2012 ×1

t-sql ×1

xml ×1