 |
|
ในการlogin อยากให้ตรวจสอบตัวพิมพ์เล็กกับพิมพ์ใหญ่ว่ามันต่างกัน? |
|
 |
|
|
 |
 |
|
ในการlogin อยากให้ตรวจสอบตัวพิมพ์เล็กกับพิมพ์ใหญ่ว่ามันต่างกัน?
คือตอนนี้ในฐานข้อมูล มี Username ชิ้อ Admin
แต่พอกรอก username ใน vb ชื่อ ADMIN มันดันเข้าระบบได้
โด้ดในปุ่มOK
Code (VB.NET)
Try
If (txtuser.Text = "") Then
MessageBox.Show("กรุณากรอก user", "เข้าสู่ระบบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtuser.Focus()
Exit Sub
End If
If (txtpass.Text = "") Then
MessageBox.Show("กรุณากรอก pass", "เข้าสู่ระบบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtpass.Focus()
Exit Sub
End If
strSQL = "SELECT * FROM Tb_User WHERE [Username] = '" & Me.txtuser.Text & "' AND [Password] = '" & Me.txtpass.Text & "' "
da = New OleDbDataAdapter(strSQL, con)
da.Fill(dt)
If dt.Rows.Count > 0 Then
If dt.Rows(0)("User") = "Admin" Then
MessageBox.Show("ยินดีต้อนรับคุณ Admin", "เข้าสู่ระบบ", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Else
MessageBox.Show("User or Pass ผิด", "เข้าสู่ระบบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtuser.Text = ""
txtpass.Text = ""
End If
con.Close()
Catch ex As Exception
MessageBox.Show("เกิดข้อผิดพลาด เนื่องจาก " & ex.Message, "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
Tag : .NET, Ms Access, VS 2012 (.NET 4.x)
|
|
 |
 |
 |
 |
Date :
2016-01-28 19:50:21 |
By :
peemes101 |
View :
2452 |
Reply :
14 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็ดีแล้วนิครับ
โดยทั่วไป User name ควรเป็น Case Insensitive
|
 |
 |
 |
 |
Date :
2016-01-28 20:46:15 |
By :
watcharop |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แต่อยากให้เมื่อกรอก username ใน vb ว่า ADMIN
ขึ้่นว่าเตือนว่า " user ไม่ถูกต้อง"
แต่ที่ถูกควรจะกรอกว่า Admin
ควรทำอย่างไร
|
ประวัติการแก้ไข 2016-01-29 01:18:06
 |
 |
 |
 |
Date :
2016-01-28 23:31:44 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แต่ผมอยากให้กรอกแบบถูกทุกตัวอักษรอ่ะ
ถ้าผิด1ตัว ก็ผิดเลย
|
 |
 |
 |
 |
Date :
2016-01-30 07:50:41 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ติดตรงไหนรึ
|
 |
 |
 |
 |
Date :
2016-01-30 12:35:30 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าเป็นโค้ดของผม
ไม่ถูกทุกตัวอักษรก็เข้าได้
คือตั้งusernameในฐานข้อมูลคือ Admin
แต่พอกรอกในvb ว่า ADMIN ดันเข้าได้ซะงั้น
ถ้าเป็นโค้ดของคุณ
ผมไม่ได้ตั้งusername และ pass ยากขนาดนั้น
โดยสิ่งที่ต้องการคือ ต้องกรอกusername ให้ตรงกับ ที่ตั้งusernameในฐานข้อมูลเป๊ะๆ
|
 |
 |
 |
 |
Date :
2016-01-30 14:02:06 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เข้าใจผิดแล้วครับ
ที่ให้ดูมันคือ XOR ต่างหาก 55555
|
 |
 |
 |
 |
Date :
2016-01-30 14:57:30 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วมันช่วยในสิ่งที่ผมต้องการได้หรือป่าว
|
 |
 |
 |
 |
Date :
2016-01-30 15:18:24 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าใช้เป็นก็ได้ครับ
พื้นฐานที่ จขกท. ต้องการคือรหัส char ถ้าจะพูดแบบบ้านๆให้อนุบาลเข้าใจคือ
A=65,a=97
Admin>> 65,100,109,105,110
ADMIN>>65,68,77,73,78
คิดให้ ป.1 ดูก็คงตอบได้ครับว่ามันคนละชุดกัน
ของดีส่วนใหญ่มักแพง ถ้าอยากได้ของดีและไม่แพง ก็ต้องทำเอง 55555
|
 |
 |
 |
 |
Date :
2016-01-30 15:55:33 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือusernameในฐานข้อมูลของผมมันสามารถเปลี่ยนได้
แล้วยังงี้จะทำยังไงให้ตัวเลขนี้เปลี่ยนตามusername ที่เปลี่ยนละครับ
และcodeของคุณมีแบบ vb มั้ยครับ
|
 |
 |
 |
 |
Date :
2016-01-30 16:57:45 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้ลองทำแบบ case sensitive ดู
ซึ่งตอนนี้ ถ้าพิม Admin ไม่สามารถเข้าได้แล้ว โดยต้องพิม admin ถึงเข้าได้
แต่ไม่รู้จะเงื่อนไขให้ไปตรวจสอบ username คนอื่นได้อย่างไง แบบแยกกัน?
โดยถ้าเป็น user1 เข้ามา จะเพิ่ม MessageBox.Show("ถูกกก คุณคือ 2")
ดังนั้นเขียนเงื่อนไขอย่างไรดี
โดยฐานข้อมูลเป็นดังนี้
table.gifUsername Password User
admin name1
user1 name2
user2 name3
user3 name4
Code (VB.NET)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim uname As String
Dim passWord As String
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Tb_User WHERE [Username] = '" & Me.txtuser.Text & "' AND [Password] = '" & Me.txtpass.Text & "' ", con)
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim sdr As OleDbDataReader = cmd.ExecuteReader()
While (sdr.Read())
uname = sdr("Username")
passWord = sdr("Password")
End While
sdr.Close()
If (uname = txtuser.Text.ToString()) Then
MessageBox.Show("ถูกกก คุณคือ 1")
Form1.Show()
Else
MessageBox.Show("ผิดดด")
End If
End Sub
|
ประวัติการแก้ไข 2016-01-31 09:18:16 2016-01-31 09:20:26
 |
 |
 |
 |
Date :
2016-01-31 09:14:46 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|