温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Ajax之用户注册实例源码
当前文件:
AjaxCheckUser/App_Code/logon.cs[2K,2009-6-12 11:31:35],打开代码结构图
AjaxCheckUser/App_Code/logon.cs[2K,2009-6-12 11:31:35],打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Web; 5
using System.Web.Security; 6
using System.Web.UI; 7
using System.Web.UI.WebControls; 8
using System.Web.UI.WebControls.WebParts; 9
using System.Web.UI.HtmlControls; 10
using System.Data.SqlClient; 11
//该源码下载自www.51aspx.com(51aspx.com) 12
13
/// <summary> 14
/// logon 的摘要说明 15
/// </summary> 16
public class logon 17
{ 18
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbuser"].ConnectionString); 19
public logon() 20
{ 21
// 22
// TODO: 在此处添加构造函数逻辑 23
// 24
} 25
public bool chklogon(string uername, string password) 26
{ 27
// string name = uername; 28
// string pwd = password; 29
// String str = "select top 1 password from info where username='"+name+"'"; 30
// SqlCommand cmd = new SqlCommand(str, con); 31
// try 32
// { 33
// con.Open(); 34
35
// SqlDataReader resu = cmd.ExecuteReader(); 36
37
// if (resu.Read()) 38
// { 39
// if (resu.GetValue(0).ToString() == pwd) 40
// { 41
// return true; 42
// } 43
// else 44
// { 45
// return false; 46
// } 47
// } 48
//51-A-s-p-x.com 49
// } 50
// catch (Exception ex) 51
// { 52
// throw (ex); 53
// } 54
// finally 55
// { 56
// con.Close(); 57
// } 58
59
// return false; 60
// //if(name.Equals(str)) 61
String T_name = uername; 62
63
String T_pass = password; 64
65
String sql = "select * from info where UserName='" + T_name + "' and Password='" + T_pass + "'"; 66
67
SqlCommand cmd = new SqlCommand(sql, con); 68
69
try 70
{ 71
con.Open(); 72
73
SqlDataReader da = cmd.ExecuteReader(); 74
75
if (da.Read()) 76
{ 77
return true; 78
} 79
else 80
{ 81
return false; 82
} 83
} 84
catch (Exception ex) 85
{ 86
throw (ex); 87
} 88
finally 89
{ 90
con.Close(); 91
} 92
} 93
} 94









