je suis débutante en programmation de service web avec .net voici mon code si vous pouvez m'aider
using System;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Web.Mail;
using System.Text.RegularExpressions;
[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 Service : System.Web.Services.WebService
{
private SqlConnection conn = new SqlConnection();
public Service () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
private string strConn = "Server=localhost;Database=cnas;Uid=root;Pwd=;";
[WebMethod(Description = "Total")]
public bool Ajouter_Total(Int64 N_carte, int code_ph, Int64 Prix_total, String Type_d)
{
conn = new SqlConnection(strConn);
string strSql = "insert into Liste_demande (carte,codep,Prix_Total,Type_D) Values (" + N_carte + "," + code_ph + "," + Prix_total + ",'" + Type_d + "')";
SqlCommand cmd = new SqlCommand(strSql, conn);
try
{
this.conn.Open();
cmd = new SqlCommand(strSql, conn);
cmd.ExecuteNonQuery();
this.conn.Close();
}
catch
{ return false; }
return true;
}
}
voici le résultat :<boolean>false</boolean>
je pense qu'il ne connecte pas à la base de donnée