相关资料:http://blog.csdn.net/yapingxin/article/details/7331375

具体操作:
1.打开“Microsoft Visual Studio 2010”->“文件”->“新建”->“项目”->“已安装的模板”->“其他语言”->“Visual C#”->“Web”->“ASP.NET 空Web应用程序”。
2.“解决方案”->“MyDataService”工程右击->“增加”->“新建项”->“已安装的模版”->“Visual C#”->“Web”->“Web 服务”。

实例代码:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.OleDb;
using System.Data;
using System.IO; namespace MyDataService
{
/// <summary>
/// WebService1 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{ [WebMethod]
public string HelloWorld()
{
return "Hello World";
} [WebMethod]
public int Add(int x, int y)
{
return x + y;
} [WebMethod]
public DataSet SelectSQL()
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=E:\\MyData.mdb");
OleDbCommand cmd = new OleDbCommand("select * from usesr", con);
OleDbDataAdapter oda = new OleDbDataAdapter();
DataSet ds = new DataSet();
DataTable dta = new DataTable();
con.Open();
oda = new OleDbDataAdapter(cmd);
oda.Fill(ds, "usesr");
return ds;
} //
[WebMethod]
public string SelectSQL2()
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=E:\\MyData.mdb");
OleDbCommand cmd = new OleDbCommand("select * from usesr", con);
OleDbDataAdapter oda = new OleDbDataAdapter();
DataSet ds = new DataSet();
DataTable dta = new DataTable();
con.Open();
oda = new OleDbDataAdapter(cmd);
oda.Fill(ds, "usesr");
//
System.Text.StringBuilder strbuilder = new System.Text.StringBuilder();
StringWriter writer = new StringWriter(strbuilder);
ds.WriteXml(writer, System.Data.XmlWriteMode.IgnoreSchema); return strbuilder.ToString(); }
[WebMethod]
public string ExecSQL(string ASQL)
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=E:\\MyData.mdb");
OleDbCommand cmd = new OleDbCommand(ASQL, con);
con.Open();
//
int num = Convert.ToInt32(cmd.ExecuteNonQuery());
if (num > )
{
string Astr;
Astr = "成功";
return Astr;
}
else
{
string Astr;
Astr = "失败";
return Astr;
}
}
}
}

VisualStudio2010中创建ASP.Net WebService的更多相关文章

  1. 【转载】在 Visual Studio 2012 中创建 ASP.Net Web Service

    在 Visual Studio 2012 中创建 ASP.Net Web Service,步骤非常简单.如下: 第一步:创建一个“ASP.Net Empty Web Application”项目 创建 ...

  2. php中创建和调用webservice接口示例

    php中创建和调用webservice接口示例   这篇文章主要介绍了php中创建和调用webservice接口示例,包括webservice基本知识.webservice服务端例子.webservi ...

  3. 在 Visual Studio 2013 中创建 ASP.NET Web 项目(0):专题导航 [持续更新中]

    写在前面的话 随着 Visual Studio 2013 的正式推出,ASP.NET 和 Visual Studio Web 开发工具 也发布了各自的最新版本. 新版本在构建 One ASP.NET ...

  4. 在 Visual Studio 2013 中创建 ASP.NET Web 项目(1):概述 - 创建 Web 应用程序项目

    注:本文是“在 Visual Studio 2013 中创建 ASP.NET Web 项目”专题的一部分,详情参见 专题导航 . 预备知识 本专题适用于 Visual Studio 2013 及以上版 ...

  5. Visual Studio 2010中创建ASP.Net Web Service

    转自:http://blog.csdn.net/xinyaping/article/details/7331375 很多人在论坛里说,在Visual Studio 2010中不能创建“ASP.Net ...

  6. (转)在 Visual Studio 2010 中创建 ASP.Net Web Service

    很多人在论坛里说,在Visual Studio 2010中不能创建“ASP.Net Web Service”这种project了,下面跟帖者云云,有的说这是因为微软已经将Web Service整合进W ...

  7. 创建ASP.NET Webservice

    一.WebService:WebService是以独立于平台的方式,通过标准的Web协议,可以由程序访问的应用程序逻辑单元. (1)应用程序逻辑单元:web服务包括一些应用程序逻辑单元或者代码.这些代 ...

  8. 如何在 Azure 中创建 ASP.NET Web 应用

    Azure Web 应用提供高度可缩放.自修补的 Web 托管服务. 本快速入门演示如何将第一个 ASP.NET Web 应用部署到 Azure Web 应用中. 完成后,便拥有了一个资源组,该资源组 ...

  9. 在 Visual Studio 2010 中创建 ASP.Net Web Service

    第一步:创建一个“ASP.Net Empty Web Application”项目 第二步:在项目中添加“Web Service”新项目 第一步之后,Visual Studio 2010会创建一个仅含 ...

随机推荐

  1. SRM589

    250: 给一个串S,可以做这样的操作,可以将串中的一种字母变成另一种字母,代价是该种字母的数量.求解的问题是,最小的代价将串S变成回文串. 根据回文关系,我们可以形成等价对应关系,a与b等价对应说明 ...

  2. POJ2253——Frogger(Floyd变形)

    Frogger DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fi ...

  3. Python之异常篇 [待更新]

    简介 当你的程序中出现某些 异常的 状况的时候,异常就发生了.例如,当你想要读某个文件的时候,而那个文件不存在.或者在程序运行的时候,你不小心把它删除了.上述这些情况可以使用异常来处理. 假如你的程序 ...

  4. 一篇文章教会你,如何做到招聘要求中的“要有扎实的Java基础

    来历 本文来自于一次和群里猿友的交流,具体的情况且听LZ慢慢道来. 一日,LZ在群里发话,“招人啦.” 然某群友曰,“群主,俺想去.” LZ回之,“你年几何?” 群友曰,“两年也.” LZ憾言之,“惜 ...

  5. node.js模块之Buffer模块

    http://nodejs.org/api/buffer.html Pure JavaScript is Unicode friendly but not nice to binary data. W ...

  6. 【转】Java多线程学习

    来源:http://www.cnblogs.com/samzeng/p/3546084.html Java多线程学习总结--线程概述及创建线程的方式(1) 在Java开发中,多线程是很常用的,用得好的 ...

  7. maven常用插件配置详解

    常用插件配置详解Java代码    <!-- 全局属性配置 --> <properties> <project.build.name>tools</proje ...

  8. 设置一个POJO的某个属性的默认值

    //月利率private BigDecimal monthRate=new BigDecimal(0);  

  9. bzoj4028

    一眼分块题…… 分块,维护每个块的总的gcd和xor和 先思考我们应该怎么查询,考虑到gcd是一个神奇的东西,因为它最多变化logX次 于是我们从前往后扫描每个块,如果一个块内总的gcd是当前扫描的前 ...

  10. 在try...catch语句中执行Response.End()后如何停止执行catch语句中的内容

    在调用Response.End()时,会执行Thread.CurrentThread.Abort()操作. 如果将Response.End()放在try...catch中,catch会捕捉Thread ...