日期:2014-05-18 浏览次数:20851 次
using System; using System.Data; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; using System.Data.SqlClient; /// <summary> /// WebService 的摘要说明 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class WebService : System.Web.Services.WebService { public WebService () { //如果使用设计的组件,请取消注释以下行 //InitializeComponent(); } [WebMethod] public string HelloWorld() { return "Hello World"; } public void ExcuteSql(string strSql) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Server=localhost;" + "Database=Hospital;" + "Integrated Security=true;"; conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = strSql; cmd.ExecuteNonQuery(); conn.Close(); conn.Dispose(); } public DataTable ExcuteSelect(string strSql) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Server=localhost;" + "Database=Hospital;" + "Integrated Security=true;"; conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = strSql; SqlDataAdapter adapter = new SqlDataAdapter(strSql,conn); DataSet ds = new DataSet(); adapter.Fill(ds, "table"); return ds.Tables["table"]; } public bool HasName(string strSql) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Server=localhost;" + "Database=Hospital;" + "Integrated Security=true;"; conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = strSql; SqlDataReader reader = cmd.ExecuteReader(); return reader.Read(); } }
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class EditInformation : System.Web.UI.Page
{
public string strSql;
WebService webS = new WebService();
public DataTable dr;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserLevel"] == null || Session["UserLevel"].ToString() != "User")
{
Response.Redirect("Error.aspx?");
}
if (Page.IsPostBack)
{
strSql = "selecet * from Enterprises_Info where Ent='" + Session["UserID"].ToString() + "';";
dr = webS.ExcuteSelect(strSql);
this.lbUser.Text=dr.Rows[0]["Ent_User"].ToString();
this.tbPsw.Text = dr.Rows[0]["Ent_Psw"].ToString();
this.tbName.Text = dr.Rows[0]["Ent_Name"].ToString();
this.lbNO.Text=dr.Rows[