ตามโค้ดค่ะ คือต้องการเช็คสถานะการ Login โดยการคลิกที่ Radio ก็จะไปคนละฟอร์ม แต่มันไม่ขึ้น Error เลยไม่รู้ผิดตรงไหนค่ะ รบกวนด้วย
Code (VB.NET)
Imports System.Windows.Forms
Imports System.Data.SqlClient
'Imports System.Data
'Imports System.Data.DataSet
'Imports System.Data.Odbc
'Imports System.Data.OleDb
Public Class Login
Dim conn As New SqlConnection
Dim cmd As New SqlCommand
Dim data As New DataTable
Dim Va_calss As String = 0
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
Dim conStr As String = "Data Source=ASUS-PC\SQLEXPRESS;Initial Catalog=DBTest;User ID=sa;Password=tomnan27;"
'Dim conn As New OleDbConnection(conStr)
'conn.Open()
Dim sql As String = "SELECT * FROM tblUser"
'Dim adapter As New OleDbDataAdapter(sql, conn)
Dim data As New DataSet()
'adapter.Fill(data, "tblUser")
Dim Username As String = ""
Dim Password As String = ""
Dim status As Integer
Dim tblUser As Boolean = False
Dim i As Integer = 0
Dim cmdLogin As Boolean = False
Dim Rb1 As Integer
For i = 0 To data.Tables("tblUser").Rows.Count - 1
status = data.Tables("tblUser").Rows(i)("status")
If Username = txtUser.Text And Password = txtPass.Text And status = Va_calss Then
cmdLogin = True
Rb1 = data.Tables("tblUser").Rows(i)("status")
End If
Next
If cmdLogin Then
If Rb1 = 1 Then
frmAddSpace.Show()
End If
If Rb1 = 2 Then
Form3.Show()
End If
Else
MsgBox("คุณกรอกข้อมูลผิด")
End If
End Sub
Private Sub Rb1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rb1.CheckedChanged
Va_calss = "1"
End Sub
Private Sub Rb2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rb2.CheckedChanged
Va_calss = "2"
End Sub
Private Sub cmdReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReset.Click
txtUser.Text = ""
txtPass.Text = ""
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Rb1 = data.Tables("tblUser").Rows(i)("status")
MsgBox(Rb1) ' เช็คดูว่ามันตรงกับที่ต้องการไม๊
End If
Next
If cmdLogin Then
If Rb1 = 1 Then
frmAddSpace.Show()
End If
If Rb1 = 2 Then
Form3.Show()
End If
Else
MsgBox("คุณกรอกข้อมูลผิด")
End If