Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > help-VB ทำหน้า login เชื่อมต่อกับ access พิมรหัสมั่วไม่ผ่าน อ่านด้านใน



 

help-VB ทำหน้า login เชื่อมต่อกับ access พิมรหัสมั่วไม่ผ่าน อ่านด้านใน

 



Topic : 031142



โพสกระทู้ ( 34 )
บทความ ( 0 )



สถานะออฟไลน์




ผมลองใช้โคดจากที่นี่ล่ะครับ
ลองแก้ซักพัก รันดูก็ผ่านเฉพาะตอนที่ใส่ ไอดี พาสเวิด ถูดเท่านั้น
แต่พอลองใส่มั่วๆดู กับติดบั๊ก
มันบอกมาอย่างนี้

No data exists for the row/column.

โค๊ดที่ผมใช้
Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_ok.Click
Cnnstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Projects\login_test\login_test\bin\database\user_login.mdb;"
With Cnn
If .State = ConnectionState.Open Then Close()
.ConnectionString = Cnnstring
.Open()
.Close()
End With
If username.Text = "" Or password_txt.Text = "" Then
MessageBox.Show("ใส่ข้อมูล", "No UserID", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
ReadMyData(Cnnstring)
End If
End Sub
Public Sub ReadMyData(ByVal myConnString As String)
On Error GoTo 0
With Cnn
If .State = ConnectionState.Open Then Close()
.ConnectionString = Cnnstring
.Open()
End With
SqlSelect = "select * from user_db Where idname = '" & username.Text & "' and Password = '" & password_txt.Text & "'"
Dim OleCommand As New OleDbCommand(SqlSelect, Cnn)
OleReader = OleCommand.ExecuteReader
OleReader.Read()
str_idname = OleReader.Item("idname")
str_password = OleReader.Item("password")
Cnn.Close()
If username.Text = str_idname And password_txt.Text = str_password Then
goods.Show()
username.Text = ""
password_txt.Text = ""
Me.Hide()
Else
MessageBox.Show("กรุณาใส่ข้อมูลให้ถูกต้อง", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If


End Sub

เหมือนกับว่า if else จะไม่ทำงานอย่างนั้นล่ะ ใครช่วยได้บอกทีครับ มือใหม่ๆ



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-09-01 18:55:30 By : phoenix69 View : 5489 Reply : 4
 

 

No. 1



โพสกระทู้ ( 26 )
บทความ ( 0 )



สถานะออฟไลน์


Code (VB.NET)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_ok.Click
Cnnstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Projects\login_test\login_test\bin\database\user_login.mdb;"
With Cnn
If .State = ConnectionState.Open Then Close()
.ConnectionString = Cnnstring
.Open()
.Close()
End With
If username.Text = "" Or password_txt.Text = "" Then
MessageBox.Show("ใส่ข้อมูล", "No UserID", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
ReadMyData(Cnnstring)
End If
End Sub
Public Sub ReadMyData(ByVal myConnString As String)
On Error GoTo 0
With Cnn
If .State = ConnectionState.Open Then Close()
.ConnectionString = Cnnstring
.Open()
End With
SqlSelect = "select * from user_db Where idname = '" & username.Text & "' and Password = '" & password_txt.Text & "'"
Dim OleCommand As New OleDbCommand(SqlSelect, Cnn)
OleReader = OleCommand.ExecuteReader
OleReader.Read()
str_idname = OleReader.Item("idname")
str_password = OleReader.Item("password")
Cnn.Close()
If username.Text = str_idname And password_txt.Text = str_password Then
goods.Show()
username.Text = ""
password_txt.Text = ""
Me.Hide()
Else
MessageBox.Show("กรุณาใส่ข้อมูลให้ถูกต้อง", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If


End Sub







Date : 2009-09-02 14:05:47 By : saesee1125
 


 

No. 2



โพสกระทู้ ( 26 )
บทความ ( 0 )



สถานะออฟไลน์


อันก่อนหน้าพอดีผมก๊อบโค๊ดมาว่างเพื่อดูให้ง่ายขึ้นครับ
อันนี้ผมแก้แล้วน่าจะผ่านแล้วนะครับ

ที่ผิดตอนแรกคือไม่มีการ ตรวจสอบว่ามีค่าในฐานข้อมูลหรือเปล่านะครับ

Code (VB.NET)
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_ok.Click
        Cnnstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Projects\login_test\login_test\bin\database\user_login.mdb;"
        With Cnn
            If .State = ConnectionState.Open Then Close()
            .ConnectionString = Cnnstring
            .Open()
            .Close()
        End With
        If username.Text = "" Or password_txt.Text = "" Then
            MessageBox.Show("ใส่ข้อมูล", "No UserID", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Else
            ReadMyData(Cnnstring)
        End If
    End Sub

    Public Sub ReadMyData(ByVal myConnString As String)
        On Error GoTo 0
        With Cnn
            If .State = ConnectionState.Open Then Close()
            .ConnectionString = Cnnstring
            .Open()
        End With
        SqlSelect = "select * from user_db Where idname = '" & username.Text & "' and Password = '" & password_txt.Text & "'"
        Dim OleCommand As New OleDbCommand(SqlSelect, Cnn)
        OleReader = OleCommand.ExecuteReader
        OleReader.Read()
        If Not DataRDA.HasRows Then
            str_idname = OleReader.Item("idname")
            str_password = OleReader.Item("password")
        Else
            MessageBox.Show("User name or password Incorrec")
        End If

        Cnn.Close()
        If username.Text = str_idname And password_txt.Text = str_password Then
            goods.Show()
            username.Text = ""
            password_txt.Text = ""
            Me.Hide()
        Else
            MessageBox.Show("กรุณาใส่ข้อมูลให้ถูกต้อง", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
    End Sub

Date : 2009-09-02 14:14:08 By : saesee1125
 

 

No. 3



โพสกระทู้ ( 26 )
บทความ ( 0 )



สถานะออฟไลน์


เอาใหม่ครับ อันนั้นลืมแก้นิดหนึ่ง


Code (VB.NET)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_ok.Click
    Cnnstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Projects\login_test\login_test\bin\database\user_login.mdb;"
    With Cnn
        If .State = ConnectionState.Open Then Close()
        .ConnectionString = Cnnstring
        .Open()
        .Close()
    End With
    If username.Text = "" Or password_txt.Text = "" Then
        MessageBox.Show("ใส่ข้อมูล", "No UserID", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Else
        ReadMyData(Cnnstring)
    End If
End Sub

Public Sub ReadMyData(ByVal myConnString As String)
    On Error GoTo 0
    With Cnn
        If .State = ConnectionState.Open Then Close()
        .ConnectionString = Cnnstring
        .Open()
    End With
    SqlSelect = "select * from user_db Where idname = '" & username.Text & "' and Password = '" & password_txt.Text & "'"
    Dim OleCommand As New OleDbCommand(SqlSelect, Cnn)
    OleReader = OleCommand.ExecuteReader
    OleReader.Read()
    If Not OleReader.HasRows Then
        str_idname = OleReader.Item("idname")
        str_password = OleReader.Item("password")
    Else
        MessageBox.Show("User name or password Incorrec")
    End If

    Cnn.Close()
    If username.Text = str_idname And password_txt.Text = str_password Then
        goods.Show()
        username.Text = ""
        password_txt.Text = ""
        Me.Hide()
    Else
        MessageBox.Show("กรุณาใส่ข้อมูลให้ถูกต้อง", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning)
    End If
End Sub


Date : 2009-09-02 14:17:05 By : saesee1125
 


 

No. 4



โพสกระทู้ ( 34 )
บทความ ( 0 )



สถานะออฟไลน์


ไม่ได้ครับ ยังเหมือนเดิม
แถมเมื่อพิมรหัสผ่นและไอดีถูก กลับเข้าไม่ได้ด้วย
Date : 2009-09-02 17:49:00 By : phoenix69
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : help-VB ทำหน้า login เชื่อมต่อกับ access พิมรหัสมั่วไม่ผ่าน อ่านด้านใน
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่