偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

操作C# Dataset介紹

開(kāi)發(fā) 后端
本文介紹操作C# Dataset,在AJAX 開(kāi)發(fā)中,需要調(diào)用業(yè)務(wù)函數(shù),操作C# Dataset,讀取數(shù)據(jù)集,具體操作方法如下。

最近在AJAX 開(kāi)發(fā)中,需要調(diào)用業(yè)務(wù)函數(shù),操作C# Dataset,讀取數(shù)據(jù)集,具體操作方法如下:

新建一 WEB 項(xiàng)目,創(chuàng)建一業(yè)務(wù)類:操作C# Dataset代碼如下所示:

  1. using System;  
  2. using System.Data;  
  3. using System.Configuration;  
  4. using System.Web;  
  5. using System.Web.Security;  
  6. using System.Web.UI;  
  7. using System.Web.UI.WebControls;  
  8. using System.Web.UI.WebControls.WebParts;  
  9. using System.Web.UI.HtmlControls;  
  10. using System.Data.OleDb;  
  11. using System.Text;  
  12.  
  13. /**//// <summary> 
  14. /// test 的摘要說(shuō)明  
  15. /// </summary> 
  16. public class test  
  17. {  
  18. public test()  
  19. {  
  20. //  
  21. // TODO: 在此處添加構(gòu)造函數(shù)邏輯  
  22. //  
  23. }  
  24.  
  25. // 數(shù)據(jù)集傳遞測(cè)試  
  26. [Ajax.AjaxMethod()]  
  27. public DataSet GetDataSet()  
  28. {  
  29. OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
  30. Data Source=D:工作項(xiàng)目分析 estdb.mdb;Persist Security Info=True;");  
  31. DataSet ds = new DataSet();  
  32. try  
  33. {  
  34. OleDbCommand cmd = conn.CreateCommand();  
  35. cmd.CommandText = "select * from t_name";  
  36. cmd.CommandType = CommandType.Text;  
  37.  
  38. OleDbDataAdapter da = new OleDbDataAdapter(cmd);  
  39. da.Fill(ds);  
  40. return ds;  
  41. }  
  42. catch  
  43. {  
  44. conn.Close();  
  45. throw;  
  46. }  
  47. }  
  48. }創(chuàng)建好業(yè)務(wù)類以后,再新建一 Aspx 頁(yè)面,在頁(yè)面的 Page_Load 中注冊(cè)業(yè)務(wù)類: 
    protected void Page_Load(object sender, EventArgs e)  
  49. {  
  50. Ajax.Utility.RegisterTypeForAjax(typeof(test));  
  51. }頁(yè)面代碼如下: <%@ Page Language="C#" AutoEventWireup="true" 
    CodeFile="read_dataset.aspx.cs" Inherits="read_dataset" %> 
  52.  
  53. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    > 
  54. <html xmlns="http://www.w3.org/1999/xhtml"> 
  55. <head runat="server"> 
  56. <title>read_dataset</title> 
  57.  
  58. <script language="JavaScript"> 
  59.  
  60. function getDataSet()  
  61. {  
  62. var ds =test.GetDataSet().value;  
  63. if(ds != null && typeof(ds) == "object" && ds.Tables != null)  
  64. {  
  65. var s = new Array();  
  66. s[s.length] = "<table style='border: #000000 1px solid; color: #993333; 
  67. font-family: 'Microsoft Sans Serif'; background-color: #ffff99;'>";  
  68.  
  69. for(var i=0; i<ds.Tables[0].Rows.length; i++)  
  70. {  
  71. s[s.length] = "<tr>";  
  72. s[s.length] = "<td>" + ds.Tables[0].Rows[i].id + "</td>";  
  73. s[s.length] = "<td>" + ds.Tables[0].Rows[i].f_date + "</td>";  
  74. s[s.length] = "<td>" + ds.Tables[0].Rows[i].f_name + "</td>";  
  75. s[s.length] = "</tr>";  
  76. }  
  77.  
  78. s[s.length] = "</table>";  
  79. document.getElementById("div1").innerHTML = s.join("");  
  80. }  
  81. else  
  82. {  
  83. alert("調(diào)用Ajax接口函數(shù)錯(cuò)誤!");  
  84. }  
  85. }  
  86. </script> 
  87.  
  88. </head> 
  89. <body> 
  90. <form id="form1" runat="server"> 
  91. <input type="button" value="dataset" onclick="getDataSet();" /> 
  92. <div id="div1"> 
  93. </div> 
  94. </form> 
  95. </body> 
  96. </html> 

以上介紹操作C# Dataset

【編輯推薦】

  1. 概述C#實(shí)現(xiàn)文件下載
  2. C#搞定網(wǎng)站驗(yàn)證碼的方法
  3. 淺談C# String對(duì)象
  4. C#命名空間學(xué)習(xí)筆記
  5. 淺析C#調(diào)用ActiveX控件
責(zé)任編輯:佚名 來(lái)源: IT168
相關(guān)推薦

2009-08-25 17:28:23

C#創(chuàng)建DataSet

2009-08-03 17:12:40

C#指針操作

2009-08-12 18:35:36

C# ArrayLis

2009-08-25 10:24:29

C# delegate

2009-08-17 16:47:51

C# Anonymou

2009-09-02 17:20:50

C# Parsing

2009-08-10 16:30:56

C# BitmapDa

2009-08-12 09:41:28

C# Director

2009-09-03 15:57:11

C# SystemMe

2009-07-31 14:15:38

C# 構(gòu)造函數(shù)

2009-08-04 08:48:44

C#內(nèi)置特性

2009-08-18 16:45:40

C# Raw Sock

2009-08-12 15:34:40

C# DBNull

2009-08-07 16:10:20

C#調(diào)用API

2009-08-13 17:36:54

編譯C#代碼

2009-08-26 17:31:59

C# const常量

2009-09-03 09:40:57

C#創(chuàng)建表單

2009-08-21 15:16:23

C#使用指針

2009-08-06 18:15:13

C# SQL Serv

2009-09-01 16:19:57

C# new()約束
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)