如何从mysql查询中获取数据库的值? [英] How do I get the value from database in mysql query?

查看:314
本文介绍了如何从mysql查询中获取数据库的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我们有一个登录表单,程序必须检测用户分配的位置。 (选择位置是在注册期间完成的,因此用户的位置已经保存到数据库中)。据说,每个职位都有一个单独的表格。



So we're having a log-in form in which the program must detect what position the user is assigned to. (selecting position is done during sign-up, so position of the user is saved into the database already). Supposedly, there is a separate form for every position.

Dim username As String = txtUser.Text
Dim password As String = txtPass.Text

//check if username and password exist
 checklogin(username, password)
        If RS.EOF Then
            MessageBox.Show("Mismatch Entry", "confirmation Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Error)
            txtUser.Clear()
            txtUser.Focus()
        Else
            Me.Hide()
            //problem starts here
            checkposition()
            If (position == "Officer")
                OfficerForm.Show()
            Elseif (position == "Head")
                HeadForm.Show()
            Elseif (position == "Admin")
                AdminForm.Show()
            Else
             // dialog box
        End If
    End Sub



校验方法:




The method for checkposition:

Public Sub checkpositon(ByVal username As String, ByVal positon As String)
    RS = CN.Execute("SELECT position FROM admin WHERE uName = '" & username & "' ")
End Sub





知道代码中仍然缺少某些内容。我知道它有什么问题。如何将数据库中的位置检索到登录表单中?请帮助:(谢谢!



know there's still something missing in the code. and I know what's wrong with it. How will the position in the database be retrieved into the log-in form? PLEASE HELP :( Thank you!

推荐答案

Dim username As String = txtUser.Text
Dim password As String = txtPass.Text
 
//check if username and password exist
 checklogin(username, password)
        If RS.EOF Then
            MessageBox.Show("Mismatch Entry", "confirmation Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Error)
            txtUser.Clear()
            txtUser.Focus()
        Else
            Me.Hide()
            //problem starts here
            checkposition()
            If (position = "Officer")
                OfficerForm.Show()
            Elseif (position = "Head")
                HeadForm.Show()
            Elseif (position = "Admin")
                AdminForm.Show()
            Else
             // dialog box
        End If
    End Sub

这篇关于如何从mysql查询中获取数据库的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆