LuckyLuke82 LuckyLuke82 - 1 year ago 104 Question

concatenate Combobox items from Oracle DB

I want to display 2 table values from Oracle DB in combobox (name and surname). So far I can display only one, and this one also doesn't work with WHERE criteria.

Using conn As OracleConnection = New OracleConnection("Data Source=MyDB;User Id=Lucky;Password=MyPassword;")



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())
End While


Catch ex As Exception
End Try

Anybody knows how I could display name and surname together in combobox, with WHERE clause ?

Answer Source

Try using string concatenation this way

 SELECT Name ||' ' || Surname from MyTable where ID=1

if you need alignment you can try padding

 SELECT Name || RPAD(' ', (12 - length(Name),' ') ||  '-  ' || Surname from MyTable where ID=1
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download