Link to home
Start Free TrialLog in
Avatar of leeds2000
leeds2000Flag for Norway

asked on

Writing a SQL query through VB.net to oracle

Hey, i need to connect to oracle when i press a button, and ask this SQL query:

SELECT oi.vare_nr, oi.ans_nr, COUNT(*)
FROM ordreinfo oi, vare v, ansatt a
WHERE v.vare_nr = oi.vare_nr
AND a.ans_nr = oi.ans_nr
GROUP BY oi.vare_nr, oi.ans_nr;

after this i need to get the information i receive from the SQL query to a listbox, how do i do this?


I was thinking something like this (its some variables there in norwegian, but you understand :))

I dont understand how i should implement this SQL query to my code, and i dont know if this is the correct way to go :)
Dim forbindelse As New System.Data.OracleClient.OracleConnection
 
        forbindelse.ConnectionString = "user id=****;password=****;data source=oracle.*******"
        forbindelse.Open()
 
        Dim setning As String = "sql query?????"
 
 
        Dim kommando As New System.Data.OracleClient.OracleCommand(setning, forbindelse)
 
 
        Dim dataleser As OracleClient.OracleDataReader
        dataleser = kommando.ExecuteReader()

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Solar_Flare
Solar_Flare

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of leeds2000

ASKER

Okei, i will try this tomorrow, thanks for the help so far :)
Im struggling with getting the information from this SQL query to show in the listbox or a datagridview, how do i do this?
please help
Avatar of Solar_Flare
Solar_Flare

you need to make sure the datatextfield and datavaluefield are set to the appropriate field names from the query so it knows which fields to use for the text and value