Hi,
Since I am brand new to the world of VB and willing to learn I would like to know how to retrieve data from 1 column from my database use this to calculate the difference and write it back to my table
In annex you will find my current DB which is representing the fuel consumption of my car.
Currently I use excel to do the calculations but I would like to reproduce this through VB.NET
In the column kmstand you will find the last kmstand when I had to fill my car up
I know the sql command to retrieve this info
In my form I enter in my textbox the new kmstand then I need to calculate the "dagteller" dagteller = "new" kmstand - "old" kmstand(result of the above query)
the only thing is I don't know how to do this
can someone point me in the right direction
in attachment you will find the datafile
Paul
Since I am brand new to the world of VB and willing to learn I would like to know how to retrieve data from 1 column from my database use this to calculate the difference and write it back to my table
In annex you will find my current DB which is representing the fuel consumption of my car.
Currently I use excel to do the calculations but I would like to reproduce this through VB.NET
In the column kmstand you will find the last kmstand when I had to fill my car up
I know the sql command to retrieve this info
Code:
SELECT TOP 1 Verbruik.kmstand
FROM Verbruik
ORDER BY Verbruik.id DESC;the only thing is I don't know how to do this
Code:
Dim sqlQuery as string = "SELECT TOP 1 Verbruik.kmstand
FROM Verbruik
ORDER BY Verbruik.id DESC"
Dim sqlCommand as new Oledb.OledbCommand
Dim sqlAdapter As New Oledb.OledbDataAdapter
Dim Table as new DataTable
Dim NewDagteller as integer
with SqlCommand
.CommandText = SqlQuery
.Connection = conn
end with
with SqlAdapter
.SelectCommand = SqlCommand
.Fill(Table)
' I'm thinking about a construction like this but not certain that's the right syntax
NewDagteller.text = Kmstand.text - sqlQuery.can someone point me in the right direction
in attachment you will find the datafile
Paul