VBScript

Const ForReading = 1Const TristateUseDefault = -2Dim FSO Set FSO = CreateObject("Scripting.FileSystemObject") Dim FilePath FilePath = "C:\BM1707\bm1707.temp" set cn = CreateObject("ADODB.Connection") cn.connectionstring = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;DataBase=test; " &_ "USER=usr;PASSWORD=psw;" cn.open

If FSO.FileExists(FilePath) Then Dim file Set file = FSO.GetFile(FilePath) Dim TextFileStream Set TextFileStream = file.OpenAsTextStream(ForReading,TristateUseDefault) Do While Not TextFileStream.AtEndOfStream Dim line line = TextFileStream.ReadLine curday = Mid(Line,2,2) curmnth = Mid(Line,5,2) curyear = Mid(Line,8,4) curData = Mid(Line,2,10) curhour = Mid(Line,13,2) curmin = Mid(Line,16,2) cursec = Mid(Line,19,2) curdt = curyear & curmnth & curday & curhour & curmin & cursec curhour = Cint(curhour) curmin = Cint(curmin) cursec = Cint(cursec) aspdate = CDate(curData) javadt = ((((aspdate - 25569) * 24 + curhour) * 60 + curmin) * 60 + cursec) * 1000 sqlStr = "SELECT Count( * ) FROM temperatures WHERE javadatetime = " & javadt res = cn.execute(sqlStr) If res(0)="0" Then line = trim(Mid(Line,24)) cnt = 1 lst = Split(line) For Each str In lst nm = "" val = "" vals = Split(str,"=") For Each z In vals If nm = "" Then nm = z Else val = Replace(z,",",".") End If Next If (nm <> "") and (val <> "") Then cmdStr = "INSERT INTO temperatures" &_ "(measurementdatetime, thermometerid, value, javadatetime, thermometername)" &_ "VALUES ('" & curdt & "','" & cnt & "','" & val & "','" & javadt & "','" & nm & "')" cn.execute cmdStr End If cnt = cnt + 1 Next End if Loop TextFileStream.Close Set TextFileStream = NothingEnd If cn.close