Eliott
Posts: 6
|
| Posted: 04/24/2005, 3:42 AM |
|
Hi there,
I have a need that sometime export part of one table (based on SQL query) into ASCII file where fields would be delimited with some delimiters (comma, Tab, etc) but unable to do it. For example, I would like to be in position to export all records where one of field in table is checked (True) and to save to hard disk or much better to export into file on diskette. Such format of ASCII I would later to use to upload into table on other (main) computer.
Similarlly to above situation, I also need some solution for upload ASCII ordered files into table. For now, database is MS Access but later I'll change it into MySQL.
Thanks in advance.
|
 |
 |
Nicole
Posts: 586
|
| Posted: 04/25/2005, 2:59 AM |
|
Eliot,
You can try the following scenario:
- execute custom sql query;
- loop through a records of a recordset to retrieve fields data;
- copy field values to a text file. Refer to MSDN article that explains how to manipulate text files in ASP http://support.microsoft.com/default.aspx?scid=kb;en-us;300982
_________________
Regards,
Nicole |
 |
 |
Eliott
Posts: 6
|
| Posted: 04/25/2005, 4:18 AM |
|
Thanks Nicole,
I'll try to do it on this way. I hope that now it will work.
Fondly, Eliott
|
 |
 |
DonB
|
| Posted: 04/25/2005, 6:23 PM |
|
If you edit the normal html for a grid, you can replace the </TR> with a
<MR>, and all the <TD> with a comma character, then remove all the other
html tags that form the table.
This will produce output that is a comma-separated list and no code changes
are required.
Remember, the HTML describes the layout (appearance) and the code files
describe the function. It is easy to provide a completely different layout
from what you get directly out of Codecharge without adversely impacting the
code. Just edit the html to generate the layout you need. It's perfectly
acceptable and won't break CCS as long as you preserve the template tags
(things enclosed in {}, and the BEGIN, END comments that define the
functional parts of your grid or record control.
--
DonB
http://www.gotodon.com/ccbth
"Eliott" <Eliott@forum.codecharge> wrote in message
news:6426cd1f11386c@news.codecharge.com...
> Thanks Nicole,
> I'll try to do it on this way. I hope that now it will work.
> Fondly, Eliott 
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
Eliott
Posts: 6
|
| Posted: 05/02/2005, 2:33 PM |
|
Uh DonB, I'm not sure I did you understand about tags about replacement tags in my code in order to make tabing of data into columns, so I made up this version based on kind Mrs. Nicole suggestion. This version of code is working nice for me (just what I need in my question) and there are comments for newbies just like Me.
I hope that this piece of code will help to someone.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1250"%>
<html>
<head>
<title>Read Shop.mdb table Orders and save results into TXT file by Eliott</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
</head>
<body>
<%
'Part of this code is here thanks to Nicol :)
'Setup of connection
dim DB
Set DB = Server.CreateObject ("ADODB.Connection")
DB.Open ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" +"i:\Littlefloor\Shop.mdb")
Dim RS
'dimension variable for file-access:
Dim objFSO, objTextFile
Dim sRead, sReadLine, sReadAll
Const ForReading = 1, ForWriting = 2, ForAppending = 8
dim p1, p2, p3
dim vbCrLf
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Customizing of file name based on current date
dim FileOut
FileOut="Orders for " & Formatdatetime(now(),vbLongDate)
Set objTextFile = objFSO.CreateTextFile("c:\"+FileOut+".txt", True) ' where to save TxT data
'----------------
'Connection setup:
Set RS = Server.CreateObject ("ADODB.Recordset")
RS.Open "SELECT * FROM Orders where c_blocked=False", DB
'Read the data. Each field transfer into variables p1, p2, ...p3 and then send to function for writing into file
If RS.EOF And RS.BOF Then
Response.Write "There is 0 records."
Else
RS.MoveFirst
While Not RS.EOF
p1=RS.Fields ("c_codes") 'into var. p1 contents of c_codes
objTextFile.Write ("") & p1 'save into file variable p1
objTextFile.write ";" 'add delimiter semicolumn ;
p2=RS.Fields ("c_articles") 'new fields
objTextFile.Write ("") & p2
objTextFile.write ";"
p3=RS.Fields ("c_datesp")
objTextFile.Write ("") & p3
objTextFile.writeLine "" 'insert sign for new line at end of each row (record)
RS.MoveNext
Wend
End If
objTextFile.Close 'close the file
%>
</body>
</html>
|
 |
 |
RANJIT
|
| Posted: 05/08/2005, 11:34 PM |
|
EXPORT THE DATA FROM EACH TABLE INTO A COMMA SEPARATED TEXT FILE
|
|
|
 |
|