Click here to Skip to main content
14,691,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a datatable (treno1) containing 10 columns about group railway reservation. I need to know how many people loaded into a single car and how many people go to a single city.

I get a json reservation from a web.
With treno1
    .Columns.Add("Partenza", System.Type.GetType("System.String"))
    .Columns.Add("Arrivo", System.Type.GetType("System.String"))
    .Columns.Add("PNR", System.Type.GetType("System.String"))
    .Columns.Add("Classe", System.Type.GetType("System.String"))
    .Columns.Add("Cognome", System.Type.GetType("System.String"))
    .Columns.Add("Carrozza", System.Type.GetType("System.String"))
    .Columns.Add("Posto", System.Type.GetType("System.String"))
    .Columns.Add("Nome", System.Type.GetType("System.String"))
    .Columns.Add("Treno", System.Type.GetType("System.String"))
    .Columns.Add("ID prenotazione", System.Type.GetType("System.String"))
End With


For Each item As JProperty In data
    item.CreateReader()

    For Each msg As JObject In item.Values
        treno1.Rows.Add(msg("departureLocationName"), msg("arrivalLocationName"), msg("pnrCode"), msg("serviceLevel"), msg("lastName"), msg("wagon"), msg("seat"), msg("firstName"), msg("transportMeanName"), msg("Id"))
    Next
Next

I don't understand how to fill combobox1 with values from partenza and arrivo. These are columns with the departure station and arrival station.

I want combobox1 to be filled with all unique stations. An sql solution would be the best way but I can't understand how to make this query. column0 has roma,firenze,bologna;column1 has firenze,bologna,milano
at the end I want combobox1 with roma,firenze,bologna,milano (without duplicates)
thanks to all

What I have tried:

all example i read are with external db,i didn't underdstand how to make a query with a datatable (so an internal db).
which connection should i use?
Posted
Updated 8-Jul-20 22:51pm

1 solution

You are correct in your assumption to use sql, you can achieve this with joint statements.

See A DETAILED EXPLANATION with code samples on Codeproject with all the join statements -

INNER JOIN
LEFT JOIN
RIGHT JOIN
OUTER JOIN
LEFT JOIN EXCLUDING INNER JOIN
RIGHT JOIN EXCLUDING INNER JOIN
OUTER JOIN EXCLUDING INNER JOIN
   
Comments
Andre Oosthuizen 9-Jul-20 7:20am
   
Your question was about combobox, so what do you require, datagrid or combobox -
I want combobox1 to be filled with all unique stations. An sql solution would be the best way but I can't understand how to make this query. column0 has
eurostar_italia 13-Jul-20 11:21am
   
@andre i want to fill combobox1 with the info i need.
At the momenti I do it storing data in a matrix and then looping them with a for next loop.
to improve my program in another post i've been told to use sql statment;i presume you can use sql statement only with a datatable....or am'i wrong,thanks
Andre Oosthuizen 14-Jul-20 2:47am
   
You can have a look here for multiple combobox examples in Codeproject - VB>Net Combobox
eurostar_italia 14-Jul-20 11:11am
   
@andre i was wrong explaining my request : to fill a combo with a sql query,you need an ado connection.do you know how connect a datatable? I found lot of examples but only with external db (file access,sql server)
Andre Oosthuizen 14-Jul-20 11:18am
   
It all depends on what database you are using, sql, mysql etc... Many examples HERE ON CODEPROJECT
eurostar_italia 14-Jul-20 17:17pm
   
@andre,i create a datatable filling it up from a json file..a web response from a website.so i dont have to connect any external db but only use sql queries to my datable to fill listboxes and comboboxes

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900