<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<script language="VB" runat="server">
Sub A_Click(Sender As Object, E As EventArgs)
请问这怎么写呢
End Sub
</script>
<body>
<form runat="server">
<asp:TextBox BorderColor="#000000" BorderWidth="10" ID="TextBox1" runat="server" TextMode="SingleLine" />
<p>
密 码:
<asp:TextBox BorderColor="#000000" BorderWidth="10" ID="TextBox2" runat="server" TextMode="Password" /> type="text" id="TextBox2" value="" size="99" runat="server">
</form>
</body>
</html>
8 个解决方案
#1
数据库是SQL SERVER 2000
表:user
表结构:
username,pwd
表:user
表结构:
username,pwd
#2
是访问数据库(Ado.net)不会吗
http://blog.csdn.net/chengking/archive/2005/10/07/496656.aspx
http://blog.csdn.net/chengking/archive/2005/10/07/496656.aspx
#3
vb2005如何连接和操作数据库详解
http://blog.programfan.com/article.asp?id=19282
#4
这是最基本的连接数据库的问题,楼主还是找本书看吧
#5
楼上已经说的很详细了!
#6
登陆,用户名DropDownList, 自己改一下,
If TextBox1.Text = "" Then
Label1.Text = "密码不能为空"
Return
End If
Dim conn As New SqlConnection("data source=jbs;initial catalog=zls;uid=sa;pwd=;")
Dim sql As String = "select * from userlogin where userloginid=@userloginid and password=@password"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
comm.Parameters.Add(New SqlParameter("@userloginid", SqlDbType.Int))
comm.Parameters("@userloginid").Value = DropDownList1.SelectedValue
comm.Parameters.Add(New SqlParameter("@password", SqlDbType.Char, 8))
comm.Parameters("@password").Value = TextBox1.Text
Dim dr As SqlDataReader
conn.Open()
dr = comm.ExecuteReader
If dr.Read Then
Session("userloginname") = DropDownList1.SelectedItem.Text
Session("userloginid") = DropDownList1.SelectedValue
dr.Close()
comm.Cancel()
Dim sql_3 As String = "insert into userlogin_records (userloginname,usertype,logindate,enddate) values (@userloginname,'收费',getdate(),getdate())"
comm = New SqlCommand(sql_3, conn)
comm.Parameters.Add(New SqlParameter("@userloginname", SqlDbType.Char, 20))
comm.Parameters("@userloginname").Value = Session("userloginname")
comm.ExecuteNonQuery()
comm.Cancel()
Response.Redirect("Default.aspx")
Else
Label1.Text = "密码错误,请重新输入!"
TextBox1.Text = ""
End If
End Sub
If TextBox1.Text = "" Then
Label1.Text = "密码不能为空"
Return
End If
Dim conn As New SqlConnection("data source=jbs;initial catalog=zls;uid=sa;pwd=;")
Dim sql As String = "select * from userlogin where userloginid=@userloginid and password=@password"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
comm.Parameters.Add(New SqlParameter("@userloginid", SqlDbType.Int))
comm.Parameters("@userloginid").Value = DropDownList1.SelectedValue
comm.Parameters.Add(New SqlParameter("@password", SqlDbType.Char, 8))
comm.Parameters("@password").Value = TextBox1.Text
Dim dr As SqlDataReader
conn.Open()
dr = comm.ExecuteReader
If dr.Read Then
Session("userloginname") = DropDownList1.SelectedItem.Text
Session("userloginid") = DropDownList1.SelectedValue
dr.Close()
comm.Cancel()
Dim sql_3 As String = "insert into userlogin_records (userloginname,usertype,logindate,enddate) values (@userloginname,'收费',getdate(),getdate())"
comm = New SqlCommand(sql_3, conn)
comm.Parameters.Add(New SqlParameter("@userloginname", SqlDbType.Char, 20))
comm.Parameters("@userloginname").Value = Session("userloginname")
comm.ExecuteNonQuery()
comm.Cancel()
Response.Redirect("Default.aspx")
Else
Label1.Text = "密码错误,请重新输入!"
TextBox1.Text = ""
End If
End Sub
#7
#8
都是很好的建议! 值得学习
#1
数据库是SQL SERVER 2000
表:user
表结构:
username,pwd
表:user
表结构:
username,pwd
#2
是访问数据库(Ado.net)不会吗
http://blog.csdn.net/chengking/archive/2005/10/07/496656.aspx
http://blog.csdn.net/chengking/archive/2005/10/07/496656.aspx
#3
vb2005如何连接和操作数据库详解
http://blog.programfan.com/article.asp?id=19282
#4
这是最基本的连接数据库的问题,楼主还是找本书看吧
#5
楼上已经说的很详细了!
#6
登陆,用户名DropDownList, 自己改一下,
If TextBox1.Text = "" Then
Label1.Text = "密码不能为空"
Return
End If
Dim conn As New SqlConnection("data source=jbs;initial catalog=zls;uid=sa;pwd=;")
Dim sql As String = "select * from userlogin where userloginid=@userloginid and password=@password"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
comm.Parameters.Add(New SqlParameter("@userloginid", SqlDbType.Int))
comm.Parameters("@userloginid").Value = DropDownList1.SelectedValue
comm.Parameters.Add(New SqlParameter("@password", SqlDbType.Char, 8))
comm.Parameters("@password").Value = TextBox1.Text
Dim dr As SqlDataReader
conn.Open()
dr = comm.ExecuteReader
If dr.Read Then
Session("userloginname") = DropDownList1.SelectedItem.Text
Session("userloginid") = DropDownList1.SelectedValue
dr.Close()
comm.Cancel()
Dim sql_3 As String = "insert into userlogin_records (userloginname,usertype,logindate,enddate) values (@userloginname,'收费',getdate(),getdate())"
comm = New SqlCommand(sql_3, conn)
comm.Parameters.Add(New SqlParameter("@userloginname", SqlDbType.Char, 20))
comm.Parameters("@userloginname").Value = Session("userloginname")
comm.ExecuteNonQuery()
comm.Cancel()
Response.Redirect("Default.aspx")
Else
Label1.Text = "密码错误,请重新输入!"
TextBox1.Text = ""
End If
End Sub
If TextBox1.Text = "" Then
Label1.Text = "密码不能为空"
Return
End If
Dim conn As New SqlConnection("data source=jbs;initial catalog=zls;uid=sa;pwd=;")
Dim sql As String = "select * from userlogin where userloginid=@userloginid and password=@password"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
comm.Parameters.Add(New SqlParameter("@userloginid", SqlDbType.Int))
comm.Parameters("@userloginid").Value = DropDownList1.SelectedValue
comm.Parameters.Add(New SqlParameter("@password", SqlDbType.Char, 8))
comm.Parameters("@password").Value = TextBox1.Text
Dim dr As SqlDataReader
conn.Open()
dr = comm.ExecuteReader
If dr.Read Then
Session("userloginname") = DropDownList1.SelectedItem.Text
Session("userloginid") = DropDownList1.SelectedValue
dr.Close()
comm.Cancel()
Dim sql_3 As String = "insert into userlogin_records (userloginname,usertype,logindate,enddate) values (@userloginname,'收费',getdate(),getdate())"
comm = New SqlCommand(sql_3, conn)
comm.Parameters.Add(New SqlParameter("@userloginname", SqlDbType.Char, 20))
comm.Parameters("@userloginname").Value = Session("userloginname")
comm.ExecuteNonQuery()
comm.Cancel()
Response.Redirect("Default.aspx")
Else
Label1.Text = "密码错误,请重新输入!"
TextBox1.Text = ""
End If
End Sub
#7
#8
都是很好的建议! 值得学习