 |
|
ช่วยดูโค๊ดให้หน่อยครับ คือ ผมสร้าง ฟอร์ม เเก้ไข password ได้เเล้ว บันทึกได้เเล้ว เเต่อยากให้ มันตรวจสอบ ตรงที่ว่า ตรวจสอบ ชื่อ user เเละ พาสเวิส ว่าตรง ตาม user เดิมหรือไม่ |
|
 |
|
|
 |
 |
|
คือ ลองทดสอบใส่ user ที่ ผิดไป พาสเวิส ที่ไม่ถูกต้องเเล้ว เเล้วรัน ดู ไม่ไม่ขึ้น ว่า
MessageBox.Show("คุณป้อนชื่อผู้ใช้หรือรีหัสผ่านไม่ถูกต้อง!", "ผลการตรวจสอบ")
Code (VB.NET)
Dim sqlupdate As String = "select * from users where LOGINNAME='" & User.Text & "' and PASSWORD='" & Pwd.Text & "'"
If new_pwd.Text <> re_new_pwd.Text Then
MessageBox.Show("คุณป้อนรหัสผ่านใหม่ไม่ตรงกัน!", "ผลการตรวจสอบ")
Exit Sub
End If
If MessageBox.Show("คุณต้องการเปลี่ยนรหัสผ่านใหม่ ใช่หรือไม่?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
sqlupdate = "update users set PASSWORD='" & new_pwd.Text & "' where LOGINNAME='" & User.Text & "'"
Try
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConnstring
.Open()
End With
re = New SqlCommand
With re
.CommandType = CommandType.Text
If add_state = True Then
Else
.CommandText = sqlupdate
End If
.Connection = Conn
.ExecuteNonQuery()
End With
Catch ErrorToEdit As Exception
MessageBox.Show(ErrorToEdit.Message, "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
add_state = False
MessageBox.Show("เปลี่ยนรหัสผ่านเรียบร้อย", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
Else
MessageBox.Show("คุณป้อนชื่อผู้ใช้หรือรีหัสผ่านไม่ถูกต้อง!", "ผลการตรวจสอบ")
End If
Tag : .NET, Ms SQL Server 2008, Win (Windows App), VB.NET, VS 2012 (.NET 4.x)
|
ประวัติการแก้ไข 2012-07-02 13:42:34
|
 |
 |
 |
 |
Date :
2012-07-02 13:41:26 |
By :
pisansri |
View :
1178 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือผมตั้งใจอยาก ใส่รหัส ที่มันผิด ไปอะ เเล้วตอบ yes เเล้วให้มันขึ้น "คุณป้อนชื่อผู้ใช้หรือรีหัสผ่านไม่ถูกต้อง!"
ต้องเขียนโค๊ดยังไงครับ
|
ประวัติการแก้ไข 2012-07-02 18:10:01
 |
 |
 |
 |
Date :
2012-07-02 18:04:46 |
By :
pisansri |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดัน
|
 |
 |
 |
 |
Date :
2012-07-04 16:45:39 |
By :
pisansri |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Dim sql As String = "select * from users where LOGINNAME='" & User.Text.Replace("'","''") & "'"
Dim dtable as new datatable
Dim da As New SqlDataAdapter(sql,Conn)
If da.Fill(dtable)=0 Then
' แสดงข้อผิดพลาด ไม่พบชื่อผู้ใช้
Exit Sub
End If
if dtable.Rows(0)("PASSWORD").tostring<>Pwd.Text Then
' แสดงข้อผิดพลาด รหัสผ่านไม่ถูกต้อง
Exit Sub
End If
|
 |
 |
 |
 |
Date :
2012-07-04 17:18:29 |
By :
watcharop |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|