似是而非

导航

密码问题

事先声明:

Imports System.Data

Imports System.Data.OleDb

――――――――――――――――

Private ds As New DataSet

Private strcon As String = "Provider=SQLOLEDB.1;Data Source=(local);Initial Catalog=数据库名;User ID=sa;Password=sa"

Public DBcon As New OleDbConnection(strcon)

――――――――――――――――

 

登陆框:

Dim id As String = Trim(TextBox1.Text)

Dim pass As String = Trim(TextBox2.Text)

If id = "" Then

   MsgBox("请输入身份证!", MsgBoxStyle.Critical, Me.Text)

   Return

End If

If pass = "" Then

   MsgBox("请输入转变!", MsgBoxStyle.Critical, Me.Text)

   Return

End If

 

DBcon.Open()

Dim sqlStr As String = "SELECT * FROM TMMLogin where cUserid='" & id & "'"

Dim adt As New OleDbDataAdapter(sqlStr, DBcon)

ds.Clear()

adt.Fill(ds)

DBcon.Close()

If ds.Tables(0).Rows.Count = 0 Then

    MsgBox("不存在!", MsgBoxStyle.Critical, Me.Text)

    Me.TextBox1.Text = ""

    Return

End If

Dim userid As String = ds.Tables(0).Rows(0).Item("cUserid")

Dim password As String = ds.Tables(0).Rows(0).Item("cPassword")

If password <> pass Then

    MsgBox("错误!", MsgBoxStyle.Critical, Me.Text)

    Me.TextBox2.Text = ""

    Return

Else

    Me.DialogResult = DialogResult.OK

MsgBox("登陆成功!", MsgBoxStyle.Information, Me.Text)

End If

 

密码修改:

Dim pass1 As String = Me.TextBox1.Text

Dim pass2 As String = Me.TextBox2.Text

Dim pass3 As String = Me.TextBox3.Text

If pass2 <> pass3 Then

      MsgBox("Password not Same!")

      Return

ElseIf pass1 <> G_Password Then

      MsgBox("Originally Password Wrong!")

Else

      Dim sqlcmd As SqlCommand

      sqlcmd = DBcon.CreateCommand

      sqlcmd.CommandType = CommandType.Text

sqlcmd.CommandText = "update B6_reader set password='" & pass2 & "' where readno='" & G_UserName & "'"

     

DBcon.Open()

sqlcmd.ExecuteNonQuery()

DBcon.Close()

 

MsgBox("Change Password Success!")

Close()

End If

posted on 2009-11-25 13:53  似是而非  阅读(376)  评论(0编辑  收藏  举报