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 }
我的世界国际版老版
我的世界国际版正式版是一款拥有超高自由度玩法是沙盒手游,经典
我的世界国际版完整版
我的世界国际服完整版是一款十分经典好玩的mc沙盒类游戏,在海
摩托车销售模拟器内置菜单中文版
摩托车出售模拟器,又名摩托车销售模拟器,这是一个以摩托车销售
船舶模拟2020最新版
船舶模拟2020是玩法非常有意思的模拟驾驶游戏,高清3d画质
油管主播的生活2内置菜单版
油管主播的生活2内置菜单版是一款模拟养成类游戏,在这里你将体