VisualStudio2010中创建ASP.Net WebService
相关资料: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的更多相关文章
- 【转载】在 Visual Studio 2012 中创建 ASP.Net Web Service
在 Visual Studio 2012 中创建 ASP.Net Web Service,步骤非常简单.如下: 第一步:创建一个“ASP.Net Empty Web Application”项目 创建 ...
- php中创建和调用webservice接口示例
php中创建和调用webservice接口示例 这篇文章主要介绍了php中创建和调用webservice接口示例,包括webservice基本知识.webservice服务端例子.webservi ...
- 在 Visual Studio 2013 中创建 ASP.NET Web 项目(0):专题导航 [持续更新中]
写在前面的话 随着 Visual Studio 2013 的正式推出,ASP.NET 和 Visual Studio Web 开发工具 也发布了各自的最新版本. 新版本在构建 One ASP.NET ...
- 在 Visual Studio 2013 中创建 ASP.NET Web 项目(1):概述 - 创建 Web 应用程序项目
注:本文是“在 Visual Studio 2013 中创建 ASP.NET Web 项目”专题的一部分,详情参见 专题导航 . 预备知识 本专题适用于 Visual Studio 2013 及以上版 ...
- Visual Studio 2010中创建ASP.Net Web Service
转自:http://blog.csdn.net/xinyaping/article/details/7331375 很多人在论坛里说,在Visual Studio 2010中不能创建“ASP.Net ...
- (转)在 Visual Studio 2010 中创建 ASP.Net Web Service
很多人在论坛里说,在Visual Studio 2010中不能创建“ASP.Net Web Service”这种project了,下面跟帖者云云,有的说这是因为微软已经将Web Service整合进W ...
- 创建ASP.NET Webservice
一.WebService:WebService是以独立于平台的方式,通过标准的Web协议,可以由程序访问的应用程序逻辑单元. (1)应用程序逻辑单元:web服务包括一些应用程序逻辑单元或者代码.这些代 ...
- 如何在 Azure 中创建 ASP.NET Web 应用
Azure Web 应用提供高度可缩放.自修补的 Web 托管服务. 本快速入门演示如何将第一个 ASP.NET Web 应用部署到 Azure Web 应用中. 完成后,便拥有了一个资源组,该资源组 ...
- 在 Visual Studio 2010 中创建 ASP.Net Web Service
第一步:创建一个“ASP.Net Empty Web Application”项目 第二步:在项目中添加“Web Service”新项目 第一步之后,Visual Studio 2010会创建一个仅含 ...
随机推荐
- 其实,前面倒腾那么多,只是为了想玩SPRING BOOT
嘿嘿,,曲线达到.. 看来看来很多国内的速成,都不爽. 官方教程最体贴~~~:) http://docs.spring.io/spring-boot/docs/current/reference/ht ...
- Nginx-location配置指南
语法规则: location [=|~|~*|^~] /uri/ { … } = 开头表示精确匹配 ^~ 开头表示uri以某个常规字符串开头,理解为匹配 url路径即可.nginx不对url做编码,因 ...
- HDU1535——Invitation Cards(最短路径:SPAF算法+dijkstra算法)
Invitation Cards DescriptionIn the age of television, not many people attend theater performances. A ...
- RxJava学习(三)
变换 所谓变换,就是将事件序列中的对象或整个序列进行加工处理,转换成不同的事件或事件序列. 1) API 首先看一个 map() 的例子: Observable.just("images/l ...
- ASP.NET树形控件TreeView的递归绑定
来自:http://blog.csdn.net/xqf003/article/details/4958727
- WPF中映射clr namspace
1. xaml中直接映射为prefix xmlns:prefix="clr-namespace:MyApplication.Modules.Entity;assembly=MyAssembl ...
- 武汉北大青鸟解读2016年10大IT热门岗位
武汉北大青鸟解读2016年10大IT热门岗位 2016年1月5日 13:37 北大青鸟 这是IT从业者的辉煌时代,IT行业的失业率正处在历史的低点,而且有的岗位——例如网络和安全工程师以及软件开发人员 ...
- 根据block取出space_id
/*********************************************************************//** Gets the space id of a bl ...
- bzoj1305
让我们继续来练网络流: 很明显是一个最大流的问题: 二分枚举最多次数m,然后最大流判定: 具体就是男生女生都拆成两个点i1,i2,之间连一条流量为k的边(男生i1-->i2,女生i2--> ...
- 读取Excel任务列表并显示在Outlook日历上
前几天,公司发了一个任务安排,时间不固定,但要求准时到,为了给自己加一个提醒,也为了回顾一下以前的技术,特做了一个Demo. 读取Excel就不多说了,代码很简单,但支持老版本Excel和的版本Exc ...