Try
ConnectDataBase()
StrSQL = "SELECT * FROM TbUserAdmin WHERE UserAdmin='" & FrmLogin.txtUserName.Text & "'"
Mycmd = New SqlCommand(StrSQL, Mycon)
Mycmd.Connection = Mycon
MyReader = Mycmd.ExecuteReader
MyReader.Read()
If MyReader.HasRows Then
ConnectDataBaseUserAdmin()
Dim StrSQL1 As String = "SELECT CodeEM FROM TbUserAdmin WHERE UserAdmin='" & FrmLogin.txtUserName.Text & "'"
Mycmd1 = New SqlCommand(StrSQL1, Mycon)
Mycmd1.Connection = Mycon
DA = New SqlDataAdapter
DT = New DataTable
DA.SelectCommand = Mycmd1
DA.Fill(DS, "TbUserAdmin")
lblUserEmployee.Text = DS.Tables("TbUserAdmin").Rows(0).Item("CodeEM")
Else
ConnectCodeEMEmployee()
End If
Catch ex As Exception
MessageBox.Show("ไม่สามารถทำข้อมูลได้เนื่องจาก " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Public Sub LoadInfor()
Dim objConn As New SqlConnection
Dim objCmd As New SqlCommand
Dim dtAdapter As SqlDataAdapter
Dim dt As New DataTable
Dim strConnString, strSQL As String
strConnString = "Server=localhost;UID=sa;PASSWORD=;Database=mydatabase;Max Pool Size=400;Connect Timeout=600;"
objConn.ConnectionString = strConnString
objConn.Open()
strSQL = "SELECT * FROM member WHERE Username = '" & strUser & "' "
dtAdapter = New SqlDataAdapter(strSQL, objConn)
dtAdapter.Fill(dt)
If dt.Rows.Count > 0 Then
Me.lblUser.Text = strUser
Me.lblName.Text = dt.Rows(0)("Name")
Me.lblEmail.Text = dt.Rows(0)("Email")
End If
objConn.Close()
objConn = Nothing
End Sub