扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
////验证用户名是否与注册数据库中的重名!!!
Private Sub check_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles check.Click
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim dbname As String
dbname = Server.MapPath("db1.mdb")
myConnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\WebApplication1 (2)\database\db1.mdb")数据库所在的目录
If userid.Text = "" Then
Label5.Text = "error!!you must complete it"
Else
Dim checklogin As String
checklogin = "select * from users "
Dim cmd As New OleDbCommand(checklogin, myConnection)
Dim reader As OleDbDataReader
Try
myConnection.Open()
reader = cmd.ExecuteReader()
reader.Read()
If userid.Text = reader("userid") Then
Label5.Text = "the userid had been used"
Else
Label5.Text = "this userid can use"
End If
Catch err As Exception
Trace.Write(err.Message)
Label5.Text = "checked error"
Finally
If (Not myConnection Is Nothing) Then
myConnection.Close()
End If
End Try
End If
End Sub
////用户注册
Private Sub regist_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles regist.Click
Dim myConnection As OleDbConnection
Dim myCommand As OleDbCommand
Dim dbname As String
dbname = Server.MapPath("db1.mdb")
myConnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\WebApplication1 (2)\database\db1.mdb")
Dim strinsert As String
strinsert = "insert into users("
strinsert &= "u_id,u_password)"
strinsert &= "values('"
strinsert &= userid.Text & "','"
strinsert &= password.Text & "')"
Dim cmd As New OleDbCommand(strinsert, myConnection)
Dim added As Integer
Try
myConnection.Open()
added = cmd.ExecuteNonQuery
If added > 0 Then
Label5.Text = "your information is added"
Response.Redirect("home.aspx")
End If
Catch err As Exception
Trace.Write(err.Message)
Label5.Text = "added error"
Finally
If (Not myConnection Is Nothing) Then
myConnection.Close()
End If
End Try
End Sub
/////
////
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者