Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Alguem pode me ajudar com esse meu projeto? O Android conecta no WS, utiliza ele, passa os dados tudo certo, aparece a mensagem de que os dados foram gravados com sucesso, porem quando vou verificar o DB não há nenhum cadastro.
Segue abaixo o código do WS, DB e o que eu tenho aqui comigo do Android....
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Configuration;
namespace WsClientes
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://s2b.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 Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Android consumindo 'Hello World' WebService dotNet";
}
public SqlConnection getConexao()
{
String strConn = @"Data Source=FABIANO-PC;Initial Catalog=projeto;Integrated Security=True";
SqlConnection _StrConn = new SqlConnection(strConn);
return _StrConn;
}
//[WebMethod]
//public string Cadastrar(string nome, string email, string tel, string login, string senha, string cpf, string cnpj, string rzSocial)
//{
// SqlConnection _StrConn = getConexao();
// SqlCommand sqlCmd = new SqlCommand();
// sqlCmd.Connection = _StrConn;
// sqlCmd.CommandType = CommandType.Text;
// sqlCmd.CommandText = "INSERT INTO tbclientes ([clienteNome], [clienteEmail], [clienteTel], [clienteLogin], [clienteSenha], [clienteCpf], [clienteCnpj], [clienteRazaoSocial])" +
// "VALUES ('" + nome + "','" + email + "','" + tel + "','" + login + "','" + senha + "','" + cpf + "','" + cnpj + "','" + rzSocial + "')";
// _StrConn.Open();
// int i = sqlCmd.ExecuteNonQuery();
// _StrConn.Close();
// if (i > 0)
// {
// return "Cadastrado com sucesso";
// }
// return "Erro ao cadastrar";
// }
#region "Autenticar Usuário"
[WebMethod]
public long autenticar(string login, string senha)
{
clsPessoa objPessoa = new clsPessoaFis();
objPessoa.Login = login;
objPessoa.Senha = senha;
long cod = objPessoa.autenticar();
return cod;
}
#endregion
#region "Manipula Cliente Tipo Pessoa Física"
[WebMethod]
public void incluirPF(string nome, string email, string telefone, string login, string senha, string cpf)
{
clsPessoaFis objPessoa = new clsPessoaFis();
//objPessoa.Nome = nome;
//objPessoa.Email = email;
//objPessoa.Telefone = telefone;
//objPessoa.Login = login;
//objPessoa.Senha = senha;
//objPessoa.Cpf = cpf;
objPessoa.incluir(nome, email,telefone,login,senha,cpf);
}
[WebMethod]
public void alterarPF(string nome, string email, string telefone, string login, string senha, string cpf)
{
clsPessoaFis objPessoa = new clsPessoaFis();
objPessoa.Nome = nome;
objPessoa.Email = email;
objPessoa.Telefone = telefone;
objPessoa.Login = login;
objPessoa.Senha = senha;
objPessoa.Cpf = cpf;
objPessoa.alterar();
}
[WebMethod]
public DataSet obterPF(string cpf)
{
clsPessoaFis objPessoa = new clsPessoaFis();
objPessoa.Cpf = cpf;
return objPessoa.obter();
}
#endregion
#region "Manipula Cliente Tipo Pessoa Jurídica"
[WebMethod]
public void incluirPJ(string nome, string email, string telefone, string login, string senha, string cnpj, string razaoSocial)
{
clsPessoaJur objPessoa = new clsPessoaJur();
objPessoa.Nome = nome;
objPessoa.Email = email;
objPessoa.Telefone = telefone;
objPessoa.Login = login;
objPessoa.Senha = senha;
objPessoa.Cnpj = cnpj;
objPessoa.RazaoSocial = razaoSocial;
objPessoa.incluir();
}
[WebMethod]
public void alterarPJ(string nome, string email, string telefone, string login, string senha, string cnpj, string razaoSocial)
{
clsPessoaJur objPessoa = new clsPessoaJur();
objPessoa.Nome = nome;
objPessoa.Email = email;
objPessoa.Telefone = telefone;
objPessoa.Login = login;
objPessoa.Senha = senha;
objPessoa.Cnpj = cnpj;
objPessoa.RazaoSocial = razaoSocial;
objPessoa.alterar();
}
[WebMethod]
public DataSet obterPJ(string cnpj)
{
clsPessoaJur objPessoa = new clsPessoaJur();
objPessoa.Cnpj = cnpj;
return objPessoa.obter();
}
#endregion
#region "Exlui um Cliente"
[WebMethod]
public void excluir(int cod)
{
clsPessoa objPessoa = new clsPessoaFis();
objPessoa.Cod = cod;
objPessoa.excluir();
}
#endregion
}
}
Este é o código do WS
__________________________________________________________________________________________________________________
USE [projeto]
GO
/**** Object: Table [dbo].[contatoProjeto] Script Date: 05/04/2012 21:48:23 ****/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].contatoProjeto NOT NULL,
[contatoNome] varchar NOT NULL,
[contatoEmail] varchar NOT NULL,
CONSTRAINT [PK_contatoProjeto] PRIMARY KEY CLUSTERED
(
[contatoId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
Este é o DB em SQL
___________________________________________________________________________________________________________________
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.ws"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".WebService3Activity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Este é oque eu tenho aqui do android.
___________________________________________________________________________________________________________________
Não sei se fiz o post corretamente, caso não tenha feito pesso desculpas, pois acabei de criar a conta aqui neste forúm. Vlw pessoal
Carregando comentários...