易截截图软件、单文件、免安装、纯绿色、仅160KB

SQl Xml和C# Xml数据的一点操作总结

SQl Xml和C# Xml数据的一点操作总结
在此申明Xml是InfoSet数据不是字符串,所以在此强烈反对用string拼接xml。数据库可以存放xml类型数据,那么该数据的具体操作又如何了。
1.首先建立一张含有xml数据类型的表
CREATE TABLE [dbo].[TestXml](
 [ID] [bigint] IDENTITY(1,1) NOT NULL,
 [Message] [xml] NULL,
 CONSTRAINT [PK_TestXml] PRIMARY KEY CLUSTERED
(
 [ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
2.创建相应的DataSet
注意默认Message是String类型,为此我们要把它改为XDocument或则XmlDocument,如:
 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            public XDocument Message {
                get {
                    try {
                        string xmlstr=  ((string)(this[this.tableTestXml.MessageColumn]));
                       return  XDocument.Parse(xmlstr);
                    }
                    catch (global::System.InvalidCastException e) {
                        throw new global::System.Data.StrongTypingException("表“TestXml”中列“Message”的值为 DBNull。", e);
                    }
      


相关文档:

sql语言

select *from customers
 
select *from orders
 
select customers.cust_id, orders.order_num  from customers inner join orders on customers.cust_id=orders.cust_id
 
select customers.cust_id, orders.order_num  from customers left outer join orders on customers.cust_id=orde ......

sql中 in 、not in 、exists、not exists 用法和差别


exists (sql 返回结果集为真) 
not exists (sql 不返回结果集为真) 
如下: 
表A 
ID NAME 
1    A1 
2    A2 
3  A3 
表B 
ID AID NAME 
1    1 B1 
2  & ......

SQL 语句练习


–1、查找员工的编号、姓名、部门和出生日期,如果出生日期为空值,显示日期不详,并按部门排序输出,日期格式为yyyy-mm-dd。
select emp_no,emp_name,dept,isnull(convert(char(10),birthday,120),’日期不详’) birthday
from employee
order by dept
–2、查找与喻自强在同一个单位的员工姓名、 ......

SQL 2000用户自定义函数

一。SQL Server 的三种自定义函数
“自定义函数”是我们平常的说法,而“用户定义的函数”是 SQL Server 中书面的说法。
SQL Server 2000 允许用户创建自定义函数,自定义函数可以有返回值。
自定义函数分为:标量值函数或表值函数
如果 RETURNS 子句指定一种标量数据类型,则函数为标量值函数。可 ......

ASP.NET(C#)常用代码30例

1. 打开新的窗口并传送参数:
  传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
  接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString( ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号