本文介绍了如何从VB.NET 2008中的MS Access更改密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在做员工数据维护项目.在此更改密码部分中,出现更新命令语法错误.我附上我的编码.有人帮我.
谢谢你……..

Hi, I doing employee data maintenance project. In this change password section make arise update command syntax error. I attach my coding. someone help me.
thank U........

If TextBox3.Text.Length < 4 And TextBox3.Text.Length > 12 Then
            MsgBox("PASSWORD SHOULD ATLEAST 4 CHARACTER AND NOT MORE THAN 12")
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
        ElseIf TextBox2.Text = TextBox3.Text Then
            MsgBox("NEW PASSWORD IS SAME AS OLD PASSWORD")
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
        ElseIf (TextBox3.Text = TextBox4.Text) Then
            Try
                con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\SampleDB1.mdb")
                con.Open()
                Dim ds As New DataSet
da = New OleDbDataAdapter("select * from empdetails1 where empname = '" & Trim(TextBox1.Text) & "' and password = ' " & Trim(TextBox2.Text) & "'", con)
                If da.Fill(ds) Then
                    cmd = New OleDbCommand("update empdetails1 set password = '" + TextBox3.Text + "' where empname = '" + TextBox1.Text + "'", con)
                    cmd.ExecuteNonQuery()
                    MessageBox.Show("PASSWORD CHANGE SUCCESSFULLY")
                    con.Close()
                    Me.Hide()
                    Form1.Show()
                Else
                    MsgBox("INVALID PASSWORD OR USERNAME")
                    TextBox1.Text = ""
                    TextBox2.Text = ""
                    TextBox3.Text = ""
                    TextBox4.Text = ""
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        Else
            MsgBox("NEW AND RETRY PASSWORD IS NOT MATCH")
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
        End If

推荐答案

If TextBox3.Text.Length < 4 And TextBox3.Text.Length > 12 Then
            MsgBox("PASSWORD SHOULD ATLEAST 4 CHARACTER AND NOT MORE THAN 12")
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
        ElseIf TextBox2.Text = TextBox3.Text Then
            MsgBox("NEW PASSWORD IS SAME AS OLD PASSWORD")
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
        ElseIf (TextBox3.Text = TextBox4.Text) Then
            Try
                con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\SampleDB1.mdb")
                con.Open()
                cmd = New OleDbCommand("update empdetails1 set [password] = '" + TextBox3.Text + "' where empname = '" + TextBox1.Text + "'", con)
                cmd.ExecuteNonQuery()
                MessageBox.Show("PASSWORD CHANGE SUCCESSFULLY")
                con.Close()
                Me.Hide()
                Form1.Show()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        Else
            MsgBox("NEW AND RETRY PASSWORD IS NOT MATCH")
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
        End If


cmd = New OleDbCommand("update empdetails1 set password = '" & TextBox3.Text & "' where empname = '" & TextBox1.Text & "'", con)


  'TextBox1.Text = ""
  'TextBox2.Text = ""
  'TextBox3.Text = ""
  'TextBox4.Text = ""
  'Form1.show
  'If TextBox3.Text.Length < 4 And TextBox3.Text.Length > 12 Then
 
'YOUR TRY CATCH MESSAGE'
'Catch ex As Exception
'    MsgBox(ex.Message)
'End Try

To 

   'TextBox1.Text = String.Empty
   'TextBox2.Text = String.Empty
   'TextBox3.Text = String.Empty
   'TextBox4.Text = String.Empty
   'Form1.Showdialog()
   'If TextBox3.Text.Length < 4 OR TextBox3.Text.Length > 12 Then
 
'YOUR TRY CATCH MESSAGE'

Catch ex As Exception
   MessageBox.Show("Error while Chnging Password " & ex.Message & vbCrLf &  "Please contact ITC", "", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try


并请检查您的命名约定
例如:txtPassword.Text等. . .


And please Check Your Naming Convention
For ex: txtPassword.Text etc . . .


这篇关于如何从VB.NET 2008中的MS Access更改密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 00:57