home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
business-86-101-185-173.business.broadband.hu
/
business-86-101-185-173.business.broadband.hu.zip
/
business-86-101-185-173.business.broadband.hu
/
SensorProject.ZIP
/
SensorService.asmx.cs
< prev
next >
Wrap
Text File
|
2010-10-27
|
2KB
|
57 lines
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Data;
namespace SensorServer
{
/// <summary>
/// Summary description for SensorService
/// </summary>
[WebService(Namespace = "http://10.146.104.211/")]
[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 SensorService : System.Web.Services.WebService
{
[WebMethod]
public void StoreData(string password, string Value, string SensorID)
{
using (SqlConnection con = new SqlConnection(@"server=SQLSERVERNAME;database=TEMPERATUREDB;uid=sensoruser;pwd=X82xrpS1122;"))
{
con.Open();
try
{
using (SqlCommand command = new SqlCommand("StoreTemperatureData", con))
{
command.CommandType = CommandType.StoredProcedure;
SqlParameter prm;
prm = new SqlParameter("@password", SqlDbType.VarChar, 17);
prm.Value = password;
command.Parameters.Add(prm);
prm = new SqlParameter("@value", SqlDbType.Decimal);
prm.Precision = 5;
prm.Scale = 2;
prm.Value = Decimal.Parse(Value);
command.Parameters.Add(prm);
prm = new SqlParameter("@sensorid", SqlDbType.VarChar, 53);
prm.Value = SensorID;
command.Parameters.Add(prm);
command.ExecuteNonQuery();
}
}
catch (Exception ex)
{
System.IO.File.WriteAllText(@"c:\temp\sensorservice.log", ex.Message);
System.IO.File.AppendAllText(@"c:\temp\sensorservice.log", ex.StackTrace);
}
}
}
}
}