Funções dentro de um WebService
Depois de demorar um pouco para aprender a utilizar WebServices, e com a ajuda do pessoal do forum consegui passar os valores via jquery, agora estou tendo um pouco de dificuldade para chamar umas funções dentro do webservice o código que irei postar abaixo está exibindo o seguinte erro
Nenhuma sobrecarga para o método 'atualizaDados' aceita 0 argumentos
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Xml.Serialization;
using System.Data;
using MySql.Data.MySqlClient;
/// <summary>
/// Summary description for AlterarNomeCliente
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 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 AlterarNomeCliente : System.Web.Services.WebService {
string conexao = System.Configuration.ConfigurationManager.ConnectionStrings["BancoConnectionString"].ConnectionString;
string qidCliente, qNome = null;
string eventConfirm = null;
public AlterarNomeCliente () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod(EnableSession = true)]
public void atualizaDados(HttpContext context)
{
string strConexao = conexao;
string sSql = "UPDATE cliente SET nome='" + qNome.ToUpper() + "' WHERE idcliente='" + qidCliente + "'";
using (MySqlConnection conn = new MySqlConnection(strConexao))
{
MySqlCommand cmd = new MySqlCommand(sSql, conn);
conn.Open();
int i = cmd.ExecuteNonQuery();
insertLog(context);
}
}
[WebMethod(EnableSession = true)]
protected void insertLog(HttpContext context)
{
string strConexao = conexao;
string sSql = "INSERT INTO logcliente (idcliente, idusuario, idlog, infolog, datalog) values ('" + qidCliente + "', '" + context.Request.Cookies["userInfo"]["id"].ToString() + "', '1', '" + qNome + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd") + "')";
using (MySqlConnection conn = new MySqlConnection(strConexao))
{
MySqlCommand cmd = new MySqlCommand(sSql, conn);
conn.Open();
int i = cmd.ExecuteNonQuery();
if (i > 0)
{ eventConfirm = "t"; }
else
{ eventConfirm = "f"; }
}
}
[WebMethod(EnableSession = true)]
public string AlteraNome(string nome, string idCliente)
{
if ((nome == null || nome == "") || (idCliente == null || idCliente == ""))
{ return "f"; }
else
{
if (Session["userAuthentication01"] == null || Convert.ToString(Session["userAuthentication01"]) == "")
{ return "f"; }
else
{
atualizaDados();
if (eventConfirm == "t")
{ return "t"; }
else
{ return "t"; }
}
}
}
}
Se eu tento colocar context fale que nao existe esse argumento
Discussão (3)
Carregando comentários...