ado类的原理和作用是什么-pg电子平台

大家好!今天让小编来大家介绍下关于ado类的原理和作用是什么的问题,以下是酷知号的小编对此问题的归纳整理,让我们一起来看看吧。

这篇文章主要介绍“ado类的原理和作用是什么”,在日常操作中,相信很多人在ado类的原理和作用是什么问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”ado类的原理和作用是什么”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

下面介绍ado类的四种有关介绍和方法,将四个表关联在一起,并浏览这些关系。 如上例所示,customerid 使 customers 表与 orders 表相关联。 对于 customers 表中的每个客户。

以返回特定客户的订单数以及他们的 由于 orderdetails 表只包含已订购产品的 productid,orderdetails 将使用 productid 与 products 相关联,以返回 productname。 在这一关系中,products 表为父表,而 order details 表为子表。 因此,当循环访问 orderdetails 表时,将调用 getparentrow 来检索相关的 productname 值。请注意,当为 customers 表和 orders 表创建 datarelation 时,ado类没有为 createconstraints 标志指定任何值(默认为 true)。

它假定 orders 表中的所有行都具有一个存在于父 customers 表中的 customerid 值。 如果 customerid 存在于 customers 表之外的 orders 表中,则 foreignkeyconstraint 将引发异常。如果子列可能包含父列不包含的值,添加 datarelation 时请将 createconstraints 标志设置为 false。 在该中,ado类对于 orders 表和 orderdetails 表之间的 datarelation,createconstraints 标志将设置为 false。 这样,应用程序就可以返回 orderdetails 表中的所有记录并只返回 orders 表中记录的子集,而不会生成运行时异常。 该扩展示例生成以下格式的输出。

datarelationcustomerordersrelation=  customerorders.relations.add"custorders",  customerorders.tables["customers"].columns["customerid"],  customerorders.tables["orders"].columns["customerid"]);   datarelationorderdetailrelation=  customerorders.relations.add"orderdetail",  customerorders.tables["orders"].columns["orderid"],  customerorders.tables["orderdetails"].columns["orderid"],false);   datarelationorderproductrelation=  customerorders.relations.add"orderproducts",  customerorders.tables["products"].columns["productid"],  customerorders.tables["orderdetails"].columns["productid"]);   foreachdatarowcustrowincustomerorders.tables["customers"].rows)  {  console.writeline"customerid:" custrow["customerid"]);   foreachdataroworderrowincustrow.getchildrowscustomerordersrelation))  {  console.writeline"orderid:" orderrow["orderid"]);  console.writeline"\torderdate:" orderrow["orderdate"]);   foreachdatarowdetailrowinorderrow.getchildrowsorderdetailrelation))  {  console.writeline"\tproduct:"   detailrow.getparentroworderproductrelation)["productname"]);  console.writeline"\tquantity:" detailrow["quantity"]);  }  }

以上代码示例是一个扩展示例,ado类在该示例中将返回 orderdetails 表和 products 表中的值,并只返回 orders 表中记录的子集。

以上就是小编对于ado类的原理和作用是什么问题和相关问题的解答了,ado类的原理和作用是什么的问题希望对你有用!

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文链接:https://www.andon8.com/433997.html

网站地图