WEB开发网
开发学院WEB开发ASP.NET .aspx制作链接数据库并互相跳转的登录与注册 阅读

.aspx制作链接数据库并互相跳转的登录与注册

 2012-10-08 13:46:41 来源:WEB开发网   
核心提示:</td></tr><tr><td align="right">密 码:</td><td><asp:TextBox ID="Password" runat="server">&
</td></tr>
<tr><td align="right">密 码:</td><td>
<asp:TextBox ID="Password" runat="server"></asp:TextBox></td><td>
<asp:Label ID="Label2" runat="server"></asp:Label>
</td></tr>
<tr><td>再次输入密码:</td><td>
<asp:TextBox ID="Password2" runat="server"></asp:TextBox></td><td>
<asp:Label ID="Label3" runat="server"></asp:Label>
</td></tr>
<tr><td></td><td> <asp:Button ID="Button1" runat="server" Text="确定"
Xonclick="Button1_Click" />  
<asp:Button ID="Button2" runat="server" Text="注册" Xonclick="Button2_Click" /></td><td></td></tr>
</table>
</div>
</form>
</body>
</html>
WebDengLu.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
namespace Webdenglu
{
public partial class WebDengLu1 : System.Web.UI.Page
{
string sqlserverstr = ConfigurationManager.ConnectionStrings["sqlservercon"].ConnectionString;

private void IncErrorTimes()
{
using (SqlConnection conn = new SqlConnection(sqlserverstr))
{
conn.Open();
using (SqlCommand updateCmd = conn.CreateCommand())
{
updateCmd.CommandText = "update Mebiuss Set ErrorTimes=ErrorTimes+1 Where UserName=@UserName";
updateCmd.Parameters.Add(new SqlParameter("UserName", username.Text));
updateCmd.ExecuteNonQuery();
}
}
}
private void ResetErrorTimes()
{
using (SqlConnection conn = new SqlConnection(sqlserverstr))
{
conn.Open();
using (SqlCommand updateCmd = conn.CreateCommand())
{
updateCmd.CommandText = "update Mebiuss Set ErrorTimes=0 Where UserName=@UserName";
updateCmd.Parameters.Add(new SqlParameter("UserName", username.Text));
updateCmd.ExecuteNonQuery();
}
}
}

protected void Page_Load(object sender, EventArgs e)
{
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(sqlserverstr))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "select * from Mebiuss where UserName=@UserName";
cmd.Parameters.Add(new SqlParameter("UserName", username.Text));
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
}
else { Label1.Text = "用户名不存在!"; }
}

上一页  1 2 3 4 5 6  下一页

Tags:aspx 制作 链接

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接