Silverlight 调用WebService 服务查询数据库

来源:互联网 发布:淘宝装修网店服务平台 编辑:程序博客网 时间:2024/05/18 03:29
          using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using MySql.Data.MySqlClient;
using System.Text;
using UPPC.Config;
using System.Configuration;
using System.Web.SessionState;
using System.Xml.Serialization;

namespace UPPC.ClientBin
{
    /// <summary>
    /// Summary description for EmployeesInfoWebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.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 EmployeesInfoWebService : System.Web.Services.WebService
    {     
        [WebMethod]
        public bool GetIfNeedCompare(string ChartCmd)
        {
            bool IfneedCompare = false;

            MySqlCommand Cmd = new MySqlCommand();

            string ConnectionString = ConfigurationManager.ConnectionStrings["uppc_monitoring_systemConnectionString"].ConnectionString;  //WebConfig        connectionStrings

            MySqlConnection Conn = new MySqlConnection(ConnectionString);

            Conn.Open();

            Cmd.Connection = Conn;

            Cmd.CommandTimeout = 15;

            Cmd.CommandType = System.Data.CommandType.Text;

            Cmd.CommandText = ChartCmd;

            MySqlDataReader reader1 = Cmd.ExecuteReader();

            reader1.Read();

            if (reader1.HasRows)
            {
                IfneedCompare = reader1.GetBoolean("Need_Compare");
            }

            reader1.Close();

            Conn.Close();

            return IfneedCompare;
        }
    }
}


原创粉丝点击