Hi All.

I have developed an application for booking meeting rooms. A user has to log in before he / she can use the system.

I want the user name of that user to be shown in the form.

I thaught this was easy.

Please see my code below for the log in form

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        Dim cmd As New SqlCommand("Select Name,Password from Users Where Name = '" & cmbBoxUsers.Text & "' and password = '" & txtBoxPassword.Text & "'", conn)
        Dim dr As SqlDataReader
        dr = cmd.ExecuteReader

        If dr.Read Then
            MsgBox("Login Accepted")
            MRMMain.Show()
            Me.Dispose()
        Else
            MsgBox("Login Failed, Please Try Again")
            cmbBoxUsers.Focus()
            txtBoxPassword.Focus()
        End If

        MRMMain.Text = cmbBoxUsers
    End Sub

    
End Class

I am getting this error on the line "MRMMain.Text = cmbBoxUsers"

Value of type System Windows Forms ComboBox cannot be converted to string

can anyone help me out with this.

Thanks very much

John

Recommended Answers

All 2 Replies

MRMMain.Text = cmbBoxUsers.TEXT
MRMMain.Text = cmbBoxUsers.TEXT

Spectacular

Thankyou very much

John

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.