B
brendan.mcgrath
Hi All
DB - SQL Express 2005
ST - ASP VBScript
Dev Env OS - Win XP IIS5
I am trying to retrieve records from the DB and write them into a csv
file/display onscreen for further processing. What is happening is the
records are retrieved but when I write them into the file or display
them on screen only the first and ninth fields display (fAddress1 &
description) all the rest just come out blank.
If I comment out the first field then the 2nd and ninth display and so
on.
I have tried loading the data into individual variables but the same
still happens and this is now begining to get rather annoying ;-]
Code is below for writing the file:-
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="/mws/Connections/connsmp.asp" -->
<%
varSQL = "SELECT TEstJob.fNotes, TEstJob.fUserID,
TEstJob.fInitialLoggedBy, TEstJob.fInitialLogDateTime, "
varSQL = varSQL & "TEstJob.fClientOrderNo,
TEstJob.fEngsSubiesAssigned2NonCompleteVisits, TEstSite.fName AS
SITENAME, "
varSQL = varSQL & "TEstContact.fName AS CONTACTNAME,
TEstContact.fDirectPhoneNo, TEstContact.fAddressPostCode,
TEstContact.fAddressCounty, "
varSQL = varSQL & "TEstContact.fAddressCity, TEstContact.fAddressArea,
TEstContact.fAddress2, TEstContact.fAddress1, "
varSQL = varSQL & "TEstJobType.fName AS JOBTYPENAME,
est_groups.description "
varSQL = varSQL & "FROM TEstJob LEFT JOIN TEstSite ON TEstJob.fSite =
TEstSite.fID "
varSQL = varSQL & "LEFT JOIN TEstContact ON TEstSite.fSiteAddress =
TEstContact.fID "
varSQL = varSQL & "LEFT JOIN TEstJobType ON TEstJob.fJobType =
TEstJobType.fUserID "
varSQL = varSQL & "LEFT JOIN est_groups ON TEstJob.fInitialLoggedBy =
est_groups.fid "
varSQL = varSQL & "WHERE TEstJob.fJobStatus = 4"
Dim rsJobs
Dim rsJobs_numRows
Set rsJobs = Server.CreateObject("ADODB.Recordset")
rsJobs.ActiveConnection = MM_connsmp_STRING
rsJobs.Source = varSQL
rsJobs.CursorType = 0
rsJobs.CursorLocation = 2
rsJobs.LockType = 1
rsJobs.Open()
rsJobs_numRows = 0
%>
<%
If NOT rsJobs.EOF Then
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set theFile = FSO.CreateTextFile(Server.MapPath("/MWS/jobs.csv"),
true, false)
While Not rsJobs.EOF
varRecordLine = rsJobs.Fields.Item("fAddress1").Value & "," &
rsJobs.Fields.Item("fAddress2").Value & ","
varRecordLine = varRecordLine &
rsJobs.Fields.Item("fAddressArea").Value & "," &
rsJobs.Fields.Item("fAddressCity").Value & ","
varRecordLine = varRecordLine &
rsJobs.Fields.Item("fAddressCounty").Value & "," &
rsJobs.Fields.Item("fAddressPostCode").Value & ","
varRecordLine = varRecordLine & rsJobs.Fields.Item("fUserID").Value
& "," & rsJobs.Fields.Item("CONTACTNAME").Value & ","
varRecordLine = varRecordLine &
rsJobs.Fields.Item("description").Value & "," &
rsJobs.Fields.Item("fInitialLogDateTime").Value & ","
varRecordLine = varRecordLine &
rsJobs.Fields.Item("fDirectPhoneNo").Value & "," &
rsJobs.Fields.Item("JOBTYPENAME").Value & ","
varRecordLine = varRecordLine & rsJobs.Fields.Item("fNotes").Value &
"," &
rsJobs.Fields.Item("fEngsSubiesAssigned2NonCompleteVisits").Value
theFile.WriteLine(varRecordLine)
rsJobs.MoveNext()
Wend
theFile.Close
rsJobs.Close()
Set rsJobs = Nothing
Set FSO = Nothing
Response.Redirect("/MWS/jobs.csv")
End If
%>
DB - SQL Express 2005
ST - ASP VBScript
Dev Env OS - Win XP IIS5
I am trying to retrieve records from the DB and write them into a csv
file/display onscreen for further processing. What is happening is the
records are retrieved but when I write them into the file or display
them on screen only the first and ninth fields display (fAddress1 &
description) all the rest just come out blank.
If I comment out the first field then the 2nd and ninth display and so
on.
I have tried loading the data into individual variables but the same
still happens and this is now begining to get rather annoying ;-]
Code is below for writing the file:-
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="/mws/Connections/connsmp.asp" -->
<%
varSQL = "SELECT TEstJob.fNotes, TEstJob.fUserID,
TEstJob.fInitialLoggedBy, TEstJob.fInitialLogDateTime, "
varSQL = varSQL & "TEstJob.fClientOrderNo,
TEstJob.fEngsSubiesAssigned2NonCompleteVisits, TEstSite.fName AS
SITENAME, "
varSQL = varSQL & "TEstContact.fName AS CONTACTNAME,
TEstContact.fDirectPhoneNo, TEstContact.fAddressPostCode,
TEstContact.fAddressCounty, "
varSQL = varSQL & "TEstContact.fAddressCity, TEstContact.fAddressArea,
TEstContact.fAddress2, TEstContact.fAddress1, "
varSQL = varSQL & "TEstJobType.fName AS JOBTYPENAME,
est_groups.description "
varSQL = varSQL & "FROM TEstJob LEFT JOIN TEstSite ON TEstJob.fSite =
TEstSite.fID "
varSQL = varSQL & "LEFT JOIN TEstContact ON TEstSite.fSiteAddress =
TEstContact.fID "
varSQL = varSQL & "LEFT JOIN TEstJobType ON TEstJob.fJobType =
TEstJobType.fUserID "
varSQL = varSQL & "LEFT JOIN est_groups ON TEstJob.fInitialLoggedBy =
est_groups.fid "
varSQL = varSQL & "WHERE TEstJob.fJobStatus = 4"
Dim rsJobs
Dim rsJobs_numRows
Set rsJobs = Server.CreateObject("ADODB.Recordset")
rsJobs.ActiveConnection = MM_connsmp_STRING
rsJobs.Source = varSQL
rsJobs.CursorType = 0
rsJobs.CursorLocation = 2
rsJobs.LockType = 1
rsJobs.Open()
rsJobs_numRows = 0
%>
<%
If NOT rsJobs.EOF Then
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set theFile = FSO.CreateTextFile(Server.MapPath("/MWS/jobs.csv"),
true, false)
While Not rsJobs.EOF
varRecordLine = rsJobs.Fields.Item("fAddress1").Value & "," &
rsJobs.Fields.Item("fAddress2").Value & ","
varRecordLine = varRecordLine &
rsJobs.Fields.Item("fAddressArea").Value & "," &
rsJobs.Fields.Item("fAddressCity").Value & ","
varRecordLine = varRecordLine &
rsJobs.Fields.Item("fAddressCounty").Value & "," &
rsJobs.Fields.Item("fAddressPostCode").Value & ","
varRecordLine = varRecordLine & rsJobs.Fields.Item("fUserID").Value
& "," & rsJobs.Fields.Item("CONTACTNAME").Value & ","
varRecordLine = varRecordLine &
rsJobs.Fields.Item("description").Value & "," &
rsJobs.Fields.Item("fInitialLogDateTime").Value & ","
varRecordLine = varRecordLine &
rsJobs.Fields.Item("fDirectPhoneNo").Value & "," &
rsJobs.Fields.Item("JOBTYPENAME").Value & ","
varRecordLine = varRecordLine & rsJobs.Fields.Item("fNotes").Value &
"," &
rsJobs.Fields.Item("fEngsSubiesAssigned2NonCompleteVisits").Value
theFile.WriteLine(varRecordLine)
rsJobs.MoveNext()
Wend
theFile.Close
rsJobs.Close()
Set rsJobs = Nothing
Set FSO = Nothing
Response.Redirect("/MWS/jobs.csv")
End If
%>