hello All.
i am using the FSO to write a text file derived from a
database..
see code.
however i am getting a 'permission denied' error message:
Error Type:
Microsoft VBScript runtime (0x800A0046)
Permission denied
/invoice/nv_rebuild.asp, line 101
what an i doing wrong here?..
or maybe someone has some example code that works!.
Help!..
_____code starts here________
<%@ LANGUAGE="vbscript" %>
<%
Option Explicit
Response.Buffer = TRUE
Dim strSqlTxt
Dim strInvoiceNo
Dim strInvoiceDate
Dim strDivisionCode
Dim strCustCode
Dim strLaborHours
Dim strLaborCost
Dim strEstimateNo
Dim strAmount
Dim strEquipNo
Dim strWorkOrderNo
Dim strMaterialCost
Dim strEstimateLaborHours
Dim strEstimateLaborCost
Dim strEstimateMaterialCost
Dim strTotalWorkCost
Dim conntemp
Dim rstemp
Dim strStreamLine
Dim objFSO
Dim objTStream
Dim objFileObject
RebuildInvoices()
Sub RebuildInvoices()
SetSqlRebuildInvoices()
OpenInvoiceConnect()
Do Until rstemp.EOF
SetInvoiceValues()
WriteValues()
OpenOutFile()
StreamOutFile()
rstemp.MoveNext
Loop
objTStream.Close
CloseInvoiceConnect()
End Sub
Sub SetSqlRebuildInvoices()
strSqlTxt = "SELECT "
strSqlTxt = strSqlTxt & "a.invoice_no, "
strSqlTxt = strSqlTxt & "a.invoice_date, "
strSqlTxt = strSqlTxt & "a.division_code, "
strSqlTxt = strSqlTxt & "a.cust_code, "
strSqlTxt = strSqlTxt & "a.labor_hrs, "
strSqlTxt = strSqlTxt & "a.labor_cost, "
strSqlTxt = strSqlTxt & "a.material_cost, "
strSqlTxt = strSqlTxt & "a.amount, "
strSqlTxt = strSqlTxt & "b.estimate_no, "
strSqlTxt = strSqlTxt & "b.work_order_no, "
strSqlTxt = strSqlTxt & "c.equip_no, "
strSqlTxt = strSqlTxt & "c.labor_hrs AS
estimate_labor_hours, "
strSqlTxt = strSqlTxt & "c.labor_cost AS
estimate_labor_cost, "
strSqlTxt = strSqlTxt & "c.material_cost AS
estimate_material_cost "
strSqlTxt = strSqlTxt & "FROM "
strSqlTxt = strSqlTxt
& "gblsql.tradedepot.dbo.invoice_header A, "
strSqlTxt = strSqlTxt & "gblsql.tradedepot.dbo.work_order
B, "
strSqlTxt = strSqlTxt
& "gblsql.tradedepot.dbo.equip_damage_list C "
strSqlTxt = strSqlTxt & "WHERE "
strSqlTxt = strSqlTxt & "a.invoice_no BETWEEN '310801'
AND '310850' "
strSqlTxt = strSqlTxt & "AND a.invoice_no = b.invoice_no "
strSqlTxt = strSqlTxt & "AND c.estimate_no =
b.estimate_no "
strSqlTxt = strSqlTxt & "ORDER BY "
strSqlTxt = strSqlTxt & "a.invoice_no "
End Sub
Sub SetInvoiceValues()
strInvoiceNo = rstemp("invoice_no")
strInvoiceDate = rstemp("invoice_date")
strDivisionCode = rstemp("division_code")
strCustCode = rstemp("cust_code")
strLaborHours = rstemp("labor_hrs")
strLaborCost = rstemp("labor_cost")
strMaterialCost = rstemp("material_cost")
strAmount = rstemp("amount")
strEstimateNo = rstemp("estimate_no")
strWorkOrderNo = rstemp("work_order_no")
strEquipNo = rstemp("equip_no")
strEstimateLaborHours = rstemp("estimate_labor_hours")
strEstimateLaborCost = rstemp("estimate_labor_cost")
strEstimateMaterialCost = rstemp("estimate_material_cost")
strTotalWorkCost = Cint(strEstimateLaborCost) +
Cint(strEstimateMaterialCost)
End Sub
Sub OpenOutFile()
Set objFSO = Server.CreateObject
("Scripting.FileSystemObject")
Set objTStream = objFSO.CreateTextFile
("C:\downloads\invoice.txt", True,
False)
End Sub
Sub StreamOutFile()
strStreamLine = strInvoiceNo & strInvoiceDate &
strDivisionCode &
strCustCode & strLaborHours & strLaborCost &
strMaterialCost & strAmount &
strEstimateNo & strLaborCost & strAmount & strWorkOrderNo
& strEquipNo &
strEstimateLaborHours & strEstimateLaborCost &
strEstimateMaterialCost &
strTotalWorkCost
objTStream.Writeline strStreamLine
End Sub
Sub WriteValues()
response.write strInvoiceNo
response.write strInvoiceDate
response.write strDivisionCode
response.write strCustCode
response.write strLaborHours
response.write strLaborCost
response.write strMaterialCost
response.write strAmount
response.write strEstimateNo
response.write strLaborCost
response.write strAmount
response.write strWorkOrderNo
response.write strEquipNo
response.write strEstimateLaborHours
response.write strEstimateLaborCost
response.write strEstimateMaterialCost
response.write strTotalWorkCost
response.write "<br>"
End Sub
Sub OpenInvoiceConnect()
set conntemp = server.createobject("adodb.connection")
conntemp.Open "Provider=sqloledb;Data
Source=GBLSQL;Initial
Catalog=tradedepot;User Id=tradedepot;Password=tradedepot"
set rstemp = conntemp.execute(strSqlTxt)
End Sub
Sub CloseInvoiceConnect()
rstemp.Close
Set conntemp = NOTHING
End Sub
%>
_______code ends here _______________