DataSet 添加数据集、行、列、主键和外键等操作示例
2005-10-13 21:30
555 查看
前台代码:html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>CodeUse</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="CodeUse" method="post" runat="server">
<FONT face="宋体">
<asp:button id="btnCreate" style="Z-INDEX: 100; LEFT: 31px; POSITION: absolute; TOP: 43px" runat="server" Height="36" Width="130" Text="创建数据集和数据表"></asp:button>
<asp:Button id="btnUpdateDs" style="Z-INDEX: 117; LEFT: 35px; POSITION: absolute; TOP: 439px" runat="server" Height="36px" Width="131px" Text="赋值"></asp:Button>
<asp:Label id="Label3" style="Z-INDEX: 112; LEFT: 352px; POSITION: absolute; TOP: 395px" runat="server">列号:</asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 111; LEFT: 209px; POSITION: absolute; TOP: 395px" runat="server">行号:</asp:Label>
<asp:Button id="btnUpdateMID" style="Z-INDEX: 107; LEFT: 37px; POSITION: absolute; TOP: 330px" runat="server" Height="36" Width="131" Text="修改MasterID"></asp:Button>
<asp:Button id="btnAddForeign" style="Z-INDEX: 106; LEFT: 35px; POSITION: absolute; TOP: 278px" runat="server" Height="36" Width="131" Text="添加外键"></asp:Button>
<asp:Button id="Button1" style="Z-INDEX: 105; LEFT: 31px; POSITION: absolute; TOP: 217px" runat="server" Height="36px" Width="130px" Text="添加唯一键"></asp:Button><asp:button id="btnAddRow" style="Z-INDEX: 102; LEFT: 31px; POSITION: absolute; TOP: 161px" runat="server" Height="36px" Width="130px" Text="添加行"></asp:button><asp:button id="btnAddColumn" style="Z-INDEX: 101; LEFT: 31px; POSITION: absolute; TOP: 102px" runat="server" Height="36px" Width="130px" Text="添加列"></asp:button><asp:datagrid id="dgMaster" style="Z-INDEX: 103; LEFT: 242px; POSITION: absolute; TOP: 40px" runat="server" Height="120px" Width="485px"></asp:datagrid><asp:datagrid id="dgChild" style="Z-INDEX: 104; LEFT: 240px; POSITION: absolute; TOP: 193px" runat="server" Height="111px" Width="479px"></asp:datagrid>
<asp:TextBox id="tbRow" style="Z-INDEX: 108; LEFT: 275px; POSITION: absolute; TOP: 395px" runat="server" Width="54px"></asp:TextBox>
<asp:TextBox id="tbCol" style="Z-INDEX: 109; LEFT: 422px; POSITION: absolute; TOP: 395px" runat="server" Width="64px"></asp:TextBox>
<asp:Label id="Label1" style="Z-INDEX: 110; LEFT: 520px; POSITION: absolute; TOP: 399px" runat="server">值:</asp:Label>
<asp:TextBox id="tbResult" style="Z-INDEX: 113; LEFT: 585px; POSITION: absolute; TOP: 394px" runat="server" Width="145px"></asp:TextBox>
<asp:Label id="Label4" style="Z-INDEX: 114; LEFT: 209px; POSITION: absolute; TOP: 344px" runat="server">表:</asp:Label>
<asp:DropDownList id="ddlTable" style="Z-INDEX: 115; LEFT: 277px; POSITION: absolute; TOP: 341px" runat="server">
<asp:ListItem Value="0">表一</asp:ListItem>
<asp:ListItem Value="1">表二</asp:ListItem>
</asp:DropDownList>
<asp:Button id="Button2" style="Z-INDEX: 116; LEFT: 35px; POSITION: absolute; TOP: 389px" runat="server" Height="36px" Width="131px" Text="求值"></asp:Button></FONT></form>
</body>
</HTML>
后台代码:cs
using 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;
namespace DsAndXML
如何把利用DataSet的GetXml()方法获得的字符串再转成DataSet对象
DataSet ds = db.ExecSqlForDataSet( strSQL );
string strDS = ds.GetXml();
//如何把strDS转换成DataSet对象??
--------------------------------------------------------------------------------
String strDS = ""
System.IO.StringReader reader = new System.IO.StringReader(strDS);
ds.ReadXml(reader);
reader.Close();
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>CodeUse</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="CodeUse" method="post" runat="server">
<FONT face="宋体">
<asp:button id="btnCreate" style="Z-INDEX: 100; LEFT: 31px; POSITION: absolute; TOP: 43px" runat="server" Height="36" Width="130" Text="创建数据集和数据表"></asp:button>
<asp:Button id="btnUpdateDs" style="Z-INDEX: 117; LEFT: 35px; POSITION: absolute; TOP: 439px" runat="server" Height="36px" Width="131px" Text="赋值"></asp:Button>
<asp:Label id="Label3" style="Z-INDEX: 112; LEFT: 352px; POSITION: absolute; TOP: 395px" runat="server">列号:</asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 111; LEFT: 209px; POSITION: absolute; TOP: 395px" runat="server">行号:</asp:Label>
<asp:Button id="btnUpdateMID" style="Z-INDEX: 107; LEFT: 37px; POSITION: absolute; TOP: 330px" runat="server" Height="36" Width="131" Text="修改MasterID"></asp:Button>
<asp:Button id="btnAddForeign" style="Z-INDEX: 106; LEFT: 35px; POSITION: absolute; TOP: 278px" runat="server" Height="36" Width="131" Text="添加外键"></asp:Button>
<asp:Button id="Button1" style="Z-INDEX: 105; LEFT: 31px; POSITION: absolute; TOP: 217px" runat="server" Height="36px" Width="130px" Text="添加唯一键"></asp:Button><asp:button id="btnAddRow" style="Z-INDEX: 102; LEFT: 31px; POSITION: absolute; TOP: 161px" runat="server" Height="36px" Width="130px" Text="添加行"></asp:button><asp:button id="btnAddColumn" style="Z-INDEX: 101; LEFT: 31px; POSITION: absolute; TOP: 102px" runat="server" Height="36px" Width="130px" Text="添加列"></asp:button><asp:datagrid id="dgMaster" style="Z-INDEX: 103; LEFT: 242px; POSITION: absolute; TOP: 40px" runat="server" Height="120px" Width="485px"></asp:datagrid><asp:datagrid id="dgChild" style="Z-INDEX: 104; LEFT: 240px; POSITION: absolute; TOP: 193px" runat="server" Height="111px" Width="479px"></asp:datagrid>
<asp:TextBox id="tbRow" style="Z-INDEX: 108; LEFT: 275px; POSITION: absolute; TOP: 395px" runat="server" Width="54px"></asp:TextBox>
<asp:TextBox id="tbCol" style="Z-INDEX: 109; LEFT: 422px; POSITION: absolute; TOP: 395px" runat="server" Width="64px"></asp:TextBox>
<asp:Label id="Label1" style="Z-INDEX: 110; LEFT: 520px; POSITION: absolute; TOP: 399px" runat="server">值:</asp:Label>
<asp:TextBox id="tbResult" style="Z-INDEX: 113; LEFT: 585px; POSITION: absolute; TOP: 394px" runat="server" Width="145px"></asp:TextBox>
<asp:Label id="Label4" style="Z-INDEX: 114; LEFT: 209px; POSITION: absolute; TOP: 344px" runat="server">表:</asp:Label>
<asp:DropDownList id="ddlTable" style="Z-INDEX: 115; LEFT: 277px; POSITION: absolute; TOP: 341px" runat="server">
<asp:ListItem Value="0">表一</asp:ListItem>
<asp:ListItem Value="1">表二</asp:ListItem>
</asp:DropDownList>
<asp:Button id="Button2" style="Z-INDEX: 116; LEFT: 35px; POSITION: absolute; TOP: 389px" runat="server" Height="36px" Width="131px" Text="求值"></asp:Button></FONT></form>
</body>
</HTML>
后台代码:cs
using 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;
namespace DsAndXML
如何把利用DataSet的GetXml()方法获得的字符串再转成DataSet对象
DataSet ds = db.ExecSqlForDataSet( strSQL );
string strDS = ds.GetXml();
//如何把strDS转换成DataSet对象??
--------------------------------------------------------------------------------
String strDS = ""
System.IO.StringReader reader = new System.IO.StringReader(strDS);
ds.ReadXml(reader);
reader.Close();
相关文章推荐
- DataSet 添加数据集、行、列、主键和外键等操作示例
- DataSet 添加数据集、行、列、主键和外键等操作示例(转)
- DataSet 添加数据集、行、列、主键和外键等操作示例
- DataSet 添加数据集、行、列、主键和外键等操作示例
- DataSet 添加数据集、行、列、主键和外键等操作示例
- DataSet 添加数据集、行、列、主键和外键等操作示例
- DataSet 添加数据集、行、列、主键和外键等操作示例
- DataSet 添加数据集、行、列、主键和外键等操作示例
- DataSet 添加数据集、行、列、主键和外键等操作示例
- MySql入门之一:DDL操作创建表(添加主键, 外键约束以及基本的数据类型)
- MySql之DDL操作创建表(添加主键, 外键约束以及基本的数据类型)
- DataSet用法一:添加代码创建的表DataTable,设置主键外键,读取及修改DataSet表中数据
- 数据库基本操作SQL(创建表 添加主键 添加列的常用语句)
- 为rails添加复合主键和复合外键支持
- oracle主键外键以及级联操作
- C# 用数据集Dataset批量添加记录到数据库
- mysql新建表,对表主键外键操作
- SQL语句删除和添加外键、主键的方法
- 写一个数据集DataSet---ds,向其中添加一个数据表DataTable ---dt,并创建该表的列和行。然后将本本表作为数据源绑定到GradView中。
- Oracle数据库表操作的五种约束条件(主键、外键、非空、唯一、检查)