Dim db As HyS-ql.Database = HySql.DataBaseFactory.CreateDatabase("ky2))
Dim Sql = "SELEC-T DISTINCT Name From 用户表;" '"
Dim dt As system.data.DataTable = db.ExecuteDataSet(Sql).Tables(0)
dt.TableName = "用户表" '"
Dim cm As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim dr As system.data.DataRow = cm.SelectedItem
'Dim dr As DataRow = cm.SelectedItem
dr = dt.Rows(0) '
If dr IsNot Nothing Then
e.Form.Controls("txtName").Value = dr("姓名")
e.Form.Controls("txtTel").Value = dr("电话")
End If
问题一:之前蓝代码,改为红代码就好,这里执行报错,如何解决?
报错:
无法将类型为“System.String”的对象强制转换为类型“System.Data.DataRow”。
问题一:粉红代码,在窗口打开有写,在启用按键有写,组合框这也写,有没有办法,只写一处?其他引用它?
ComboBox1下拉列表是怎么设置的?ComboBox1下拉列表SelectedIndexChanged,写一楼的代码,执行后报错
[此贴子已经被作者于2024/7/31 11:32:27编辑过]
窗口打开后事件
Dim db As HyS-ql.Database = HySq-l.DataBaseFactory.CreateDatabase("ky2))
Dim Sq-l = "SELEC-T DISTINCT Name From 用户表;" '"
[此贴子已经被作者于2024/7/31 12:04:20编辑过]
这种方式添加的下拉项目,就只是普通的字符串而已,直接赋值就行
Dim cm As WinForm.ComboBox = e.Form.Controls("ComboBox1")
e.Form.Controls("txtName").Value = cm.text
如果代码放到SelectedIndexChanged事件,一行就够了
e.Form.Controls("txtName").Value = e.sender.text
'Dim cmd As New SQ-LCommand
'cmd.C
'cmd.CommandText = "SELEC-T Group,部门,角色 From {Users} where name='" & e.sender.text & "'" '"
'e.Form.Controls("Group").text = cmd.ExecuteScalar()
报错,多字段怎么实现?
You have an error in your SQL syntax; check the manual that corresponds to your SQL server version for the right syntax to use near 'Group From xtyh_tb where name='陆一明'' at line 1
[此贴子已经被作者于2024/7/31 14:02:32编辑过]
多字段如何改实现?
[此贴子已经被作者于2024/7/31 14:27:56编辑过]