I made of the following programming VB command, running to the program itself. But is in a SQL update password cannot be updated.
It is strange that when generating executable file. Exe, the password again, no problem. Just use F5 when debugging.
Imports System. Data
Imports System. The Data. SqlClient
Public Class Form2
Dim con As SqlConnection
Dim adap As SqlDataAdapter
Dim CMD As SqlCommand
Dim ds As the DataSet
Private Sub Form2_Load (sender As Object, As EventArgs e) Handles MyBase. Load
'TODO: This line of code loads data into the' DatabaseStaffDataSet. Password 'table. You can move, or remove it, as men.
Me. PasswordTableAdapter. The Fill Me. DatabaseStaffDataSet. (Password)
End Sub
Private Sub Button1_Click (sender As Object, As EventArgs e) Handles for. Click
Try
Con=New SqlConnection (" Data Source=(LocalDB) \ v11.0; AttachDbFilename=| DataDirectory | \ DatabaseStaff. MDF; Integrated Security=True ")
Adap=New SqlDataAdapter (" SELECT * FROM [Password] where the Username='" & amp; Trim (ComboBox1. Text) & amp; "' and Pwd=" & amp; Trim (TextBox1. Text) & amp; "';" , con)
Ds=New DataSet ()
Adap. The Fill (ds, "Password")
Dim count=ds. The Tables (" Password "). The Rows. Count
If the count & gt; 0 Then
If the Trim (TextBox2. Text)=Trim (TextBox3. Text) And Len (TextBox2. Text) & gt; 2 Then
CMD=New SqlCommand ()
Cmd.Com mandText="update Password set the PWD='" & amp; Trim (TextBox2. Text) & amp; "' the where the Username='" & amp; Trim (ComboBox1. Text) & amp; "'
"MsgBox mandText (cmd.Com)
CMD. Connection=con
Con. The Open ()
CMD. ExecuteNonQuery ()
Con. The Close ()
' '???????????????????????
MsgBox (" Dear "& amp; Trim (ComboBox1. Text) & amp; ", Your password has had changed ")
ElseIf Trim (TextBox2. Text) & lt;> Trim (TextBox3. Text) Then
MsgBox (" Your new passwords do not match ", MsgBoxStyle. Critical)
ElseIf Len (TextBox2. Text) & lt; 3 Then
MsgBox (" New password must be at further 3 charactors ", MsgBoxStyle. Critical)
End the If
The Else
MsgBox (" Current password Wrong, both please check your usename and password ", MsgBoxStyle. Critical)
End the If
Catch the ex As Exception
MessageBox. Show (ex. Message)
End the Try
End Sub
End the Class
CodePudding user response:
Is most likely your VS2013 have to connect the database,Seems to be the exclusive LocalDB connection mode,
CodePudding user response: