我想在组合框(名称和姓氏)中显示来自Oracle DB的2个表值。到目前为止,我只能显示一个,而且这个也不适用于WHERE标准。
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
有人知道如何在组合框中一起显示姓名和姓氏吗?
答案 0 :(得分:1)
尝试以这种方式使用字符串连接
SELECT Name ||' ' || Surname from MyTable where ID=1
如果您需要对齐,可以尝试填充
SELECT Name || RPAD(' ', (12 - length(Name),' ') || '- ' || Surname from MyTable where ID=1