i have a MYSQL table withe one of the column type as time.
Struct of mysql table:
2 No varchar(11)
3 Name varchar(255)
4 Laps varchar(11)
5 Lap_Tm time(3)
6 Class varchar(255)</pre lang="SQL">
i have to use this QUERY in VB.net
SELECT NO,Laps, Lap_Tm,TIME_FORMAT(SEC_TO_TIME(ABS((SELECT Lap_Tm FROM raw WHERE NO = 7 AND (Lap_Tm <> '') AND Laps = 1) - Lap_Tm)), '%T.%f') AS 'diferente' FROM raw WHERE NO = 7 AND (Lap_Tm <> '') AND Laps > 1 ORDER BY diferente LIMIT 2
This query work on MYSQL
NO--Laps--Lap_Tm--diferente
7--5--00:03:56.184--00:00:00.024000
7--6--00:03:56.454--00:00:00.246000
but in vb i get input string error
I think i have to change the query to format that specific column but i do not how
please help!
What I have tried:
Public Const cs As String = "server=localhost;Uid=******;Pwd=*****;port=3306;Persist Security Info=True;database=circuit;ConvertZeroDatetime=True;Allow Zero Datetime=True;allow user variables=true"
Public Reader As MySqlDataReader
Public con As MySqlConnection
Public cmd As MySqlCommand
Dim diferentele As String = "SELECT NO,Laps, Lap_Tm,TIME_FORMAT(SEC_TO_TIME(ABS((SELECT Lap_Tm FROM raw WHERE NO = 7 AND (Lap_Tm <> '') AND Laps = 1) - Lap_Tm)), '%T.%f') AS 'diferente' FROM raw WHERE NO = 7 AND (Lap_Tm <> '') AND Laps > 1 ORDER BY diferente LIMIT 2"
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Try
con = New MySqlConnection(cs)
cmd = New MySqlCommand(diferentele, con)
con.Open()
Reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While (Reader.Read() = True)
'ListBox2.Items.Add(Reader.GetString(1).ToString())
TextBox4.Text = TextBox4.Text + ("diferente").ToString()
End While
Reader.Close()
con.Close()
Catch ex As Exception
If con.State = ConnectionState.Open Then con.Close()
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
con.Close()
con.Dispose()
End Try
End Sub