想实现不通过选择用户名,而是直接输入用户名登陆。把combobox换成textbox, afterload把combobox换成textbox显示错误
此主题相关图片如下:未标题-1.jpg
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim cmb As WinForm.Textbox = e.Form.Controls("UserName")
cmd.ConnectionName = "User"
cmd.CommandText = "SELECT DISTINCT Name F rom {Users}"
dt = cmd.ExecuteReader()
For Each dr As DataRow In dt.Datarows
cmb.Items.Add(dr("Name"))
Next
cmb.SelectedIndex = 0
请问这个代码应该怎么写?
(尝试把黄色部分删掉就不出现错误并且可以直接输入用户名登陆,但不知道这样写有没有问题?)
[此贴子已经被作者于2019/11/11 12:18:36编辑过]