I want to know how I can put each entry from the recordset to a csv/excel file. I just have a problem on how to make each entry on each line on excel and inserted to columns with no skipping spaces. The code is running in a loop. So, each line entry of the recordset is different.
Anyone familiar with readline?
here's an example of my programming code:
<% 'dim to declare variables Dim fso Dim tfile <br />Dim Verified, UID,CID, PaymentMethod,Card,CardName,CardNumber,CardExpiration
Dim ShipAddress1, ShipAddress2,ShipCity,ShipState,ShipPhone,ShipZIP Dim ShipCountry,Secure,PymtVerification ,Shipped,TrackingID
DimTimeShipped,DatePaid,Tax,SH,Total,Notes,Vnote,Processed,searchno,PONum 'set objconn to create connection to SQL database 'then open objconn set objconn= server.createobject("adodb.connection") objconn.open "Provider=SQLOLEDB; Server=webint; database=azone; uid=mwave; pwd=mwave4anson;" 'set rs (record) set to Server.CreateObject("ADODB.recordset") - this creates recordset 'then open recordset "Select * from (TableName) - have recordset open from database table, using objconn. set rs=Server.CreateObject("ADODB.recordset") rs.Open "SELECT [UID], [CID], [PaymentMethod], [SID], [ShipLastName], [ShipFirstName], [ShipAddress1], [ShipAddress2], [ShipCity], [Tax], [SH], [Total] from Purchases", objconn 'set fso to create file system object set fso = Server.CreateObject("Scripting.FileSystemObject") 'set tfile to create txtfile - somefileblah.csv set tfile = fso.CreateTextFile("\WebintwwwrootEleanorsomefileblah.csv", true) Request.ServerVariables("APPL_PHYSICAL_PATH")&"Eleanorsomefileblah.csv" 'set variables to the information within the recordset information UID = rs("uid") CID = rs("cid") PaymentMethod = rs("paymentmethod") SID = rs("sid") ShipLastName = rs("shiplastname") ShipFirstName = rs("shipfirstname") ShipAddress1 = rs("shipaddress1") ShipAddress2 = rs("shipaddress2") ShipCity = rs("shipcity") Tax = rs("tax") SH = rs("sh") Total = rs("total") 'set variable Text1 to have the string of variables UID & "," & CID &...etc Text1 = UID & "," & CID & "," & PaymentMethod & "," & SID & "," & ShipLastName & "," & ShipFirstName & "," & ShipAddress1& "," & ShipAddress2& "," & ShipCity & "," & Tax & "," & SH & "," & Total ' for each x entrys in the recordset fields
do until rs.EOF for each x in rs.Fields Response.Write(x.value) Response.Write(",") tfile.write(x.value & ",")
'if x.value is Null, fieldValue is ";" else field value is if its not null then it sets that same variable to (cStr(x.value)&" ") If IsNull(x.value) then fieldValue = "," Else fieldValue = (cStr(x.value)&" ") End If next Response.Write("")
rs.MoveNext loop 'response write to display message text created Response.Write("
'close tfile 'close objconn connection rs.close tfile.Close objconn.close 'set tfile to nothing 'set fso to nothing set tfile=nothing set fso=nothing %>