sqldatareader 检索行
1. 创建一个用来执行存储过程的 sqlcommand 对象,并将其与一个 sqlconnection 对象相关联。
2. 打开连接。
3. 通过调用 sqlcommand 对象的 executereader 方法创建一个 sqldatareader 对象。
4. 要从流中读取数据,请调用 sqldatareader 对象的 read 方法来检索行,并使用类型化访问器方法(如 getint32 和 getstring 方法)来检索列值。
5. 使用完读取器后,请调用其 close 方法。
1 public void retrieveanddisplayrowswithxmlreader()
2 {
3 using( sqlconnection conn = new sqlconnection(connectionstring) )
4 {;
5 sqlcommand cmd = new sqlcommand("datretrieveproductsxml", conn );
6 cmd.commandtype = commandtype.storedprocedure;
7 try
8 {
9 conn.open();
10 xmltextreader xreader = (xmltextreader)cmd.executexmlreader();
11 while ( xreader.read() )
12 {
13 if ( xreader.name == "products" )
14 {
15 string stroutput = xreader.getattribute("productid");
16 stroutput += " ";
17 stroutput += xreader.getattribute("productname");
18 console.writeline( stroutput );
19 }
20 }
21 xreader.close(); // xmltextreader does not support idisposable so it can't be
22 // used within a using keyword
23 }
24 }
樱花校园模拟器4399中文版
樱花校园模拟器4399中文版,十分奇趣好玩的3d校园冒险模拟
我的暑假秘密回忆繁星新春版
我的暑假秘密回忆繁星新春版是一款少女模拟养成类休闲游戏。这款
樱花校园模拟器国际版
樱花校园模拟器国际版,一个超级自由超级好玩的自由恋爱模拟的游
饥荒海难九游版
饥荒海难九游版,带你去真实的海岛上感受一下什么才是真正的孤岛
盖瑞模组体验版最新版
盖瑞模组体验版是玩法非常丰富多元化的沙盒建造游戏,玩家可以在