欧美特黄不卡,涩涩视频在线,成人国产精品一区二区网站,亚洲一区二区三区欧美

當前位置:雨林木風下載站 > 技術開發教程 > 詳細頁面

ADO 2.6 vs. the ADO.NET

ADO 2.6 vs. the ADO.NET

更新時間:2022-05-16 文章作者:未知 信息來源:網絡 閱讀次數:

ADO 2.6 vs. the ADO.NET
在本例中我們需要IIS5環境、Visual Studio.NET BETA1、還有SQL SERVER中的Northwind數據庫
在.NET中,保持了對早先COM及基于COM技術的良好支持,在本例中提供了兩種方法:GetCustomersOld() 使用了ADO2.6;GetCustomersNew() 使用ADO.NET,可以對比。

namespace PROINFO.WebService.Data
{
using System;
using System.Collections;
using System.Configuration;
using System.ComponentModel;
using System.Data;
using System.Data.SQL;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
/// <summary>
/// Summary description for WS.
/// </summary>
public class WS : System.Web.Services.WebService
{
public WS()
{
//CODEGEN: This call is required by the ASP+ Web Services Designer
InitializeComponent();
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
public override void Dispose()
{
}

// Here starts the example code
public struct sCustomers
{
public String sCustomerID;
public String sCompanyName;
public String sContactName;
public String sContactTitle;
public String sAddress;
public String sCity;
public String sRegion;
public String sPostalCode;
public String sCountry;
public String sPhone;
public String sFax;
}

[WebMethod(Description="ADO 2.6 WebMethod Example")]
public sCustomers[] GetCustomersOld()
{
ADODB.Connection cn = new ADODB.Connection();
ADODB.Recordset rs = new ADODB.Recordset();
String strSQL;
int intRC;
int intCnt;
strSQL = "SELECT * FROM Customers";
cn.Open("Provider=SQLOLEDB; Data Source=SERVER; Initial Catalog=Northwind;", "sa", null, 0);
rs.Open(strSQL, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, 0);
intRC = rs.RecordCount;
if (intRC < 1)
{
return null;
}
sCustomers[] c = new sCustomers[intRC];
rs.MoveFirst();
intCnt = 0;

while (!rs.EOF)
{
c[intCnt].sCustomerID = rs.Fields["CustomerID"].Value.ToString();
c[intCnt].sCompanyName = rs.Fields["CompanyName"].Value.ToString();
c[intCnt].sContactName = rs.Fields["ContactName"].Value.ToString();
c[intCnt].sContactTitle = rs.Fields["ContactTitle"].Value.ToString();
c[intCnt].sAddress = rs.Fields["Address"].Value.ToString();
c[intCnt].sCity = rs.Fields["City"].Value.ToString();
c[intCnt].sRegion = rs.Fields["Region"].Value.ToString();
c[intCnt].sPostalCode = rs.Fields["PostalCode"].Value.ToString();
c[intCnt].sCountry = rs.Fields["Country"].Value.ToString();
c[intCnt].sPhone = rs.Fields["Phone"].Value.ToString();
c[intCnt].sFax = rs.Fields["Fax"].Value.ToString();
rs.MoveNext();
intCnt++;
}
return c;
}

[WebMethod(Description="ADO.NET WebMethod Example")]
public DataSet GetCustomersNew()
{
DataSet ds = new DataSet();
SQLConnection cn = new SQLConnection("localhost", "sa", "", "Northwind");
cn.Open();
SQLDataSetCommand cm = new SQLDataSetCommand("SELECT * FROM Customers", cn);
cm.FillDataSet(ds, "Customers");
return ds;
}
}
}

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

主站蜘蛛池模板: 陕西省| 望谟县| 神木县| 同江市| 留坝县| 潮州市| 微山县| 富蕴县| 祁阳县| 聊城市| 淅川县| 龙川县| 白河县| 罗城| 精河县| 通化县| 抚远县| 石河子市| 定安县| 揭阳市| 颍上县| 荥阳市| 三都| 衡南县| 汉中市| 南阳市| 张北县| 石狮市| 西和县| 呼伦贝尔市| 延边| 辉南县| 洛宁县| 东明县| 常德市| 海门市| 呼伦贝尔市| 静安区| 尼玛县| 镇康县| 远安县|