using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Data; using System.Data.SqlClient; [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 { public Service () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public void AddUser(string Name, string Dates) { using (SqlConnection conn = new SqlConnection("Server=192.168.1.4;Database=HR;Trusted_Connection=True;")) { // Open a connection to the MySQL database. conn.Open(); // Add the user. using (SqlCommand cmd = new SqlCommand()) { // Initialize the command object. cmd.Connection = conn; cmd.CommandText = "INSERT INTO Holidays " + "(HolidaysName, HolidaysDate) VALUES (@0, @1)"; // Set the parameters for the command object. SqlParameter param = new SqlParameter("0", Name); cmd.Parameters.Add(param); param = new SqlParameter("1", Dates); cmd.Parameters.Add(param); // Add the record to the database. cmd.ExecuteNonQuery(); } // Close the connection. conn.Close(); } return; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)