【发布时间】:2015-07-29 09:22:17
【问题描述】:
我想我会按照一个简单的教程来创建一个 web 服务,以便我第一次开始。
我让网络服务开始工作,所以现在我想将数据添加到我的数据库中。但是,当我查看我的预览表单时,我找不到我的InsertComment void.
这是我的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
namespace MyFirstWebService
{
/// <summary>
/// Summary description for Math
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Math : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public int Add(int a, int b)
{
return (a + b);
}
[WebMethod]
public System.Single Subtract(System.Single A, System.Single B)
{
return (A - B);
}
[WebMethod]
public System.Single Multiply(System.Single A, System.Single B)
{
return A * B;
}
[WebMethod]
public System.Single Divide(System.Single A, System.Single B)
{
if (B == 0)
return -1;
return Convert.ToSingle(A / B);
}
[WebMethod]
public static void InsertComment(string value)
{
SqlParameter sqlParameter = new SqlParameter();
sqlParameter.ParameterName = "NewComment";
sqlParameter.Value = value;
List<SqlParameter> sqlParam = new List<SqlParameter>();
sqlParam.Add(sqlParameter);
SQLOperations.executeStoredProcedure("InsertNewComment", sqlParam);
}
}
}
任何关于为什么 InserComment 方法不可用的帮助都会很棒!
谢谢!
【问题讨论】:
-
@ToddB 我接受了这个问题的 mahmoud 回答,但赞成
标签: asp.net sql-server web-services