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 }
模拟极限越野
模拟极限越野开着大巴在各种奇葩路况里送乘客。山路弯道多得让人
模拟火车
模拟火车让你当回真正的火车司机,得先学会看信号灯、操作控制杆
可口的披萨美味的披萨
可口的披萨美味的披萨带您体验经营一家披萨店的乐趣。游戏画风温
定制虚拟偶像最新版
定制虚拟偶像最新版是一款超级经典有趣的日本模拟装扮类型的手游
病娇模拟器手机版正版(yandere simulator)
病娇模拟器最新版手游是一款萌妹二次元模拟游戏,玩家在游戏中可