'This file converts all Item prices and selectable options into 2 databases (1) tblprices (2) tbloptions<br>
Dim counter,fs
dim char1, char2, char3, char4, char5, char6, char7, char8, char9, char10, char11, char12, char13, char14
Dim thisfile, thisline, whichfile
'Dim VehicleOptionsSQL 'Holds the SQL query for the database
Dim TimeOut, Con, DBPath
DBPath=Session("dbpath")
TimeOut = Server.ScriptTimeout
Server.ScriptTimeout = 10000
Set Con = Server.CreateObject("ADODB.Connection")
Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & DBPath
'1st clear out all current price records in database
con.Execute("DELETE FROM tblprices")
con.Execute("DELETE FROM tbloptions")
whichfile=server.mappath("CPRNEW.A05")
Set fs = CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.OpenTextFile(whichfile, 1, False)
thisline=thisfile.readline 'Just to Read 1st Line then ignore it as it contains date information
do while not thisfile.AtEndOfStream
thisline=thisfile.readline
If left(thisline,5) <> "TOTAL" Then 'Just checking that the last line is ignored as it just gives total records
char1=left(thisline,3)' No Of Options
char2=mid(thisline,4,20)'CAP VehCode
char3=mid(thisline,24,5)'CAPVehId
char4=mid(thisline,29,15)'BasicPrice
char5=mid(thisline,44,14)'BasicVAT
char6=mid(thisline,58,15)'BasicTotal
char7=mid(thisline,73,8)'LastPriceChange
char8=mid(thisline,81,8)'LastOptionChange
con.Execute("INSERT INTO tblprices (Options, CAPVehCode, CAPVehId, BasicPrice, BasicVAT, BasicTotal, LastPriceChange, LastOptionChange) VALUES ('" & char1 & "', '" & char2 & "', '" & char3 & "', '" & char4 & "', '" & char5 & "', '" & char6 & "', '" & char7 & "', '" & char8 & "')")
response.Write("Just Inserted CAPVehId=") & char3 & ("<br>")
for counter = 0 to char1-1 'start counter at 0 due to multiplying x by 52 each time
char9=mid(thisline,89 + (counter*52),7) ' This is the Actual Option Code
char10=mid(thisline,96 + (counter*52),1) 'The Option Type
char11=mid(thisline,97 + (counter*52),15)'The Option Basic
char12=mid(thisline,112 + (counter*52),14)'OptionBasicVAT
char13=mid(thisline,126 + (counter*52),15)'OptionTotalCost
con.Execute("INSERT INTO tbloptions (CAPVehID, Code, Type, OptionBasic, OptionVAT, OptionTotal) VALUES ('" & char3 & "','" & char9 & "', '" & char10 & "', '" & char11 & "', '" & char12 & "', '" & char13 & "')")
next
end if
loop
thisfile.Close
set fs=nothing
Con.Close
Set Con = Nothing
Server.ScriptTimeout = 190