Vb.net 从Oracle数据库连接组合框项
我想在combobox中显示来自Oracle DB的2个表值(名称和姓氏)。到目前为止,我只能显示一个,这个也不适用于WHERE条件Vb.net 从Oracle数据库连接组合框项,vb.net,oracle,combobox,Vb.net,Oracle,Combobox,我想在combobox中显示来自Oracle DB的2个表值(名称和姓氏)。到目前为止,我只能显示一个,这个也不适用于WHERE条件 Using conn As OracleConnection = New OracleConnection("Data Source=MyDB;User Id=Lucky;Password=MyPassword;") Try conn.Open() Dim SQL As
Using conn As OracleConnection = New OracleConnection("Data Source=MyDB;User Id=Lucky;Password=MyPassword;")
Try
conn.Open()
Dim SQL As String
NIZ = "SELECT Name,Surname from MyTable where ID=1 "
Dim Cmd As New OracleCommand(SQL, conn)
Cmd.CommandType = CommandType.Text
Dim dr As OracleDataReader = Cmd.ExecuteReader()
While (dr.Read())
CmbCustomers.Items.Add(dr.GetString(0))
End While
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
conn.Dispose()
End Try
有人知道我如何在组合框中用WHERE子句同时显示姓名吗?尝试用这种方式使用字符串连接
SELECT Name ||' ' || Surname from MyTable where ID=1
如果需要对齐,可以尝试填充
SELECT Name || RPAD(' ', (12 - length(Name),' ') || '- ' || Surname from MyTable where ID=1
谢谢斯盖里奇,一切都很混乱。有任何选项可以全部登录文本吗?我已经用Improve对齐的建议更新了答案没有,我甚至减少到了5列,但不起作用,现在只显示1列。而且它不是名字,姓氏前面只有“-”号。你的意思是和这个完全相同的查询还是没有rpad?带rpad的完全相同的查询。。从ID=1的MyTable中选择rpad(名称,(12-长度(名称)),“*”)| |-“| |姓氏