惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Webroot Blog
Webroot Blog
U
Unit 42
A
About on SuperTechFans
宝玉的分享
宝玉的分享
月光博客
月光博客
C
CERT Recently Published Vulnerability Notes
P
Privacy International News Feed
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
P
Privacy & Cybersecurity Law Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
Securelist
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Spread Privacy
Spread Privacy
L
Lohrmann on Cybersecurity
Apple Machine Learning Research
Apple Machine Learning Research
K
Kaspersky official blog
Hugging Face - Blog
Hugging Face - Blog
B
Blog
I
Intezer
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
V
V2EX
L
LangChain Blog
AI
AI
G
GRAHAM CLULEY
T
Tor Project blog
人人都是产品经理
人人都是产品经理
D
Docker
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
I
InfoQ
Y
Y Combinator Blog
C
Comments on: Blog
GbyAI
GbyAI
www.infosecurity-magazine.com
www.infosecurity-magazine.com
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
H
Help Net Security
Vercel News
Vercel News
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿

博客园 - Jerry.liu

AspNetPager分页控件--使用方法 2 AspNetPager分页控件--使用方法 1 分析ASP.NET服务器控件开发-控件生命周期 用ObjectDataSource实现自定义分页的心得总结 DataTable操作中的性能问题 ASP.NET的 Session 详解4 ASP.NET的 Session 详解3 ASP.NET的 Session 详解2 ASP.NET的 Session 详解1 ASP.NET的 MVC框架 全面优化ADO ADO.net学习记录 (一) 彻底放弃IIS让Apache也支持ASP.NET 如何实现Asp与Asp.Net共享Session Asp.net生成htm静态文件的两种途径 ASP.NET2.0的控件状态和视图状态探讨 2 ASP.NET2.0的控件状态和视图状态探讨 1 压力监测程序sqlserver和MYSQL版 PetShop数据访问层之数据库访问设计
ADO.net学习纪录 (二)
Jerry.liu · 2007-05-25 · via 博客园 - Jerry.liu

更新数据源的方法
 
 1,Command对象
  更新需要的属性:
   Connection    包含数据仓库连接的细节
   CommandText   要运行的命令
   CommandType   命令的类型 Sql字符或存储过程的名称
          Text   表示文本字符串sql
          TableDirect 表示表名
          StoredProcedure 表示存储过程的名称
   Parameters    Parameters对象的一个集合

 2,DataAdapter对象
   注意DataAdapter和Command的区别?
   >> Command主要用于运行命令
   >> DataAdapter主要用于为多个命令提供一个存储空间,在数据仓库和DataSet之间提供    双向交互。
  哦,一个Command对象只能处理查询,添加,删除,修改中的一种
  因此 DataAdapter用四个属性存储四种Command对象
  属性如下 SelectCommand,UpdateCommand,InsertCommand,DeleteCommand  

 3,CommandBuilder对象
  OleDbCommandBuilder objBuilder
  objBuilder = new OleDbCommandBuilder(DataAdapter)
  表示告诉命令生成器可以在哪儿取到SelectCommand,以建立其他的命令.
 
  DataAdapter.UpdateCommand = objBuilder.GetUpdateCommand();
  DataAdapter.InsertCommand = objBuilder.GetInsertCommand();
  DataAdapter.DeleteCommand = objBuilder.GetDeleteCommand();
  
  注意在这种情况下,SelectCommand必需带有一个主键字段

 4.DataAdapter.Update()
  
  DataAdapter.Update(DataSet,"Tablesname");
 
 例如,以下代码确保首先处理表中已删除的行,然后处理已更新的行,然后处理已插入的行。
 [C#]
 DataTable updTable = custDS.Tables["Customers"];

 // First process deletes.
 custDA.Update(updTable.Select(null, null, DataViewRowState.Deleted));

 // Next process updates.
 custDA.Update(updTable.Select(null, null, DataViewRowState.ModifiedCurrent));

 // Finally, process inserts.
 custDA.Update(updTable.Select(null, null, DataViewRowState.Added));
 
 其中DataViewRowState数据视图的操作属性 包括Deleted, ModifiedCurrent,Added,Unchanged等
 
 至此,更新数据仓库工作完成。

[2003-05-28]
 
 使用存储过程
 
 存储过程类似于代码中的函数,它存储在数据服务器上并有一个名称。
 为什么要使用存储过程?
  1.庞大复杂的SQL语句影响程序代码的阅读
  2.由数据库服务器来处理的存储过程比直接使用SQL语句更快,效率更高
 
  要使用存储过程,需要注意的是CommandType设为StoredProccess CommandText为存储过程的名称
 
  eg: objCmd.CommandText = "[Sales by Category]";
      objCmd.CommandType = CommandType.StoreProcedure; 
 
  
使用XML
 由于ADO.net设计时就考虑到了XML,它处理XML数据就像是这些数据来自于一个数据库

 1,写入XML文件
  objAdapter.Fill(objDataSet,"Employees"); //填充结果集
  objDataSet.WriteXml(Server.MapPath("Employees.xml"));//写入到xml文件
 注意两点:
  1,首先用到了DataSet的WriteXml()方法,从DataSet中提取信息并格式化xml
  2,Server.MapPath()表示生成文件路径,指向当前应用程序的目录
 2,读取XML文件
  objDataSet.ReadXml(Server.MapPath("Employees.xml"));
 
 3,将Xml转换为字符串
  string strXML,strSchema
  strXML = objDataSet.GetXml()
  strSchema = objDataSet.GetXmlSchema()
 4,一旦XML读入到DataSet中他就同从数据库中读入的数据没有任何区别,也可以进行前面任何的
 操作,最终只要将操作的结果集DataSet写入至XML或者数据库都可以