473,554 Members | 4,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SELECT statement pulls field names - how to avoid?

I do a SELECT * from table command in an ASP page to build a text file
out on our server, but the export is not to allow a field name rows of
records. The first thing I get is a row with all the field names. Why
do these come in if they are not part of the table records? How do I
eliminate this from being produced? Here's the ASP code....
<html>

<head>
<title>Packag e Tracking Results - Client Feed</title>
</head>

<body>

<%
' define variables
dim oConn ' ADO Connection
dim oRSc ' ADO Recordset - Courier table
dim cSQLstr ' SQL string - Courier table
dim oRSn ' ADO Recordset - NAN table
dim nSQLstr ' SQL string - NAN table
dim objFSO ' FSO Connection
dim objTextFile ' Text File

' set and define FSO connection and text file object location
Set objFSO = CreateObject("S cripting.FileSy stemObject")
'Set objTextFile =
objFSO.CreateTe xtFile(Server.M apPath("textfil e.txt"))
'Response.Write (Server.MapPath ("textfile.txt" ) & "<br />")
Set objTextFile = objFSO.OpenText File("C:\textfi le.txt",2)

' write text to text file
'objTextFile.Wr iteLine "This text is in the file ""textfile.txt" "!"
' SQL strings for Courier and NAN tables
cSQLstr = "SELECT * FROM Courier"

' set and open ADO connection & oRSc recordsets
set oConn=Server.Cr eateObject("ADO DB.connection")
oConn.Open "DRIVER={Micros oft Access Driver (*.mdb)};DBQ=" &
"c:/Database/QaTracking/QaTracking.mdb" & ";"
set oRSc=Server.Cre ateObject("ADOD B.Recordset")
oRSc.Open cSQLstr, oConn

Response.Conten tType = "text/plain"
Dim i, j, tmp
If Not oRSc.EOF Then
For i = 1 To oRSc.Fields.Cou nt
objTextFile.Wri te oRSc.Fields(i-1).Name
If i < oRSc.Fields.Cou nt Then
objTextFile.Wri te " "
End If
Next
objTextFile.Wri teLine
While Not oRSc.EOF
For i = 1 To oRSc.Fields.Cou nt
If oRSc.Fields(i-1) <"" Then
tmp = oRSc.Fields(i-1)
' If TypeName(tmp) = "String" Then
' objTextFile.Wri te "" &_
'Replace(oRSc.F ields(i-1),vbCrLf,"") & ""
' Else
objTextFile.Wri te oRSc.Fields(i-1)
' End If
End If
If i < oRSc.Fields.Cou nt Then
objTextFile.Wri te " "
End If
Next
objTextFile.Wri teLine
oRSc.MoveNext
Wend
End If
objTextFile.Clo se
Set objTextFile = Nothing
Set objFSO = Nothing
oRSc.Close
Set oRSc = Nothing
oConn.Close
Set oConn = Nothing
%>

</body>
</html>

Jan 24 '07 #1
3 2710

"Billy" <Us*****@hotmai l.comwrote in message
news:11******** **************@ k78g2000cwa.goo glegroups.com.. .
>I do a SELECT * from table command in an ASP page to build a text file
out on our server, but the export is not to allow a field name rows of
records. The first thing I get is a row with all the field names. Why
do these come in if they are not part of the table records? How do I
eliminate this from being produced? Here's the ASP code....
<html>

<head>
<title>Packag e Tracking Results - Client Feed</title>
</head>

<body>

<%
' define variables
dim oConn ' ADO Connection
dim oRSc ' ADO Recordset - Courier table
dim cSQLstr ' SQL string - Courier table
dim oRSn ' ADO Recordset - NAN table
dim nSQLstr ' SQL string - NAN table
dim objFSO ' FSO Connection
dim objTextFile ' Text File

' set and define FSO connection and text file object location
Set objFSO = CreateObject("S cripting.FileSy stemObject")
'Set objTextFile =
objFSO.CreateTe xtFile(Server.M apPath("textfil e.txt"))
'Response.Write (Server.MapPath ("textfile.txt" ) & "<br />")
Set objTextFile = objFSO.OpenText File("C:\textfi le.txt",2)

' write text to text file
'objTextFile.Wr iteLine "This text is in the file ""textfile.txt" "!"
' SQL strings for Courier and NAN tables
cSQLstr = "SELECT * FROM Courier"

' set and open ADO connection & oRSc recordsets
set oConn=Server.Cr eateObject("ADO DB.connection")
oConn.Open "DRIVER={Micros oft Access Driver (*.mdb)};DBQ=" &
"c:/Database/QaTracking/QaTracking.mdb" & ";"
set oRSc=Server.Cre ateObject("ADOD B.Recordset")
oRSc.Open cSQLstr, oConn

Response.Conten tType = "text/plain"
Dim i, j, tmp
If Not oRSc.EOF Then
Remove the lines below. They are the ones that write out the name of the
fields.
For i = 1 To oRSc.Fields.Cou nt
objTextFile.Wri te oRSc.Fields(i-1).Name
If i < oRSc.Fields.Cou nt Then
objTextFile.Wri te " "
End If
Next
objTextFile.Wri teLine
Have a look at the ADO Field Object's properties. It might help you see
what you are doing:

http://www.devguru.com/Technologies/...ado_intro.html

--
Mike Brind
Jan 24 '07 #2
Billy wrote:
I do a SELECT *
:-)
Well, nothing to do with your problem, but that's mistake #1
http://www.aspfaq.com/show.asp?id=2096
from table command in an ASP page to build a text file
out on our server, but the export is not to allow a field name rows of
records. The first thing I get is a row with all the field names.
Don't write them if you don't want them. You control what gets written.
Why
do these come in if they are not part of the table records? How do I
eliminate this from being produced? Here's the ASP code....
' set and open ADO connection & oRSc recordsets
set oConn=Server.Cr eateObject("ADO DB.connection")
oConn.Open "DRIVER={Micros oft Access Driver (*.mdb)};DBQ=" &
"c:/Database/QaTracking/QaTracking.mdb" & ";"
Again, nothing to do with your problem, but this is mistake #2
http://www.aspfaq.com/show.asp?id=2126
set oRSc=Server.Cre ateObject("ADOD B.Recordset")
oRSc.Open cSQLstr, oConn

Response.Conten tType = "text/plain"
Dim i, j, tmp
If Not oRSc.EOF Then
*************** *************** ***********
For i = 1 To oRSc.Fields.Cou nt
objTextFile.Wri te oRSc.Fields(i-1).Name
If i < oRSc.Fields.Cou nt Then
objTextFile.Wri te " "
End If
Next
*************** *************** **********

As I said above, if you don't want the field names, don't write them. You
are in control of what is written. Just remove this loop.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jan 24 '07 #3
Thanks all. Commenting out the section that produced the headers
worked.

On Jan 24, 6:35 am, "Bob Barrows [MVP]" <reb01...@NOyah oo.SPAMcom>
wrote:
Billy wrote:
I do a SELECT *:-)
Well, nothing to do with your problem, but that's mistake #1http://www.aspfaq.com/show.asp?id=209 6
from table command in an ASP page to build a text file
out on our server, but the export is not to allow a field name rows of
records. The first thing I get is a row with all the field names.Don't write them if you don't want them. You control what gets written.
Why
do these come in if they are not part of the table records? How do I
eliminate this from being produced? Here's the ASP code....
' set and open ADO connection & oRSc recordsets
set oConn=Server.Cr eateObject("ADO DB.connection")
oConn.Open "DRIVER={Micros oft Access Driver (*.mdb)};DBQ=" &
"c:/Database/QaTracking/QaTracking.mdb" & ";"Again, nothing to do with your problem, but this is mistake #2http://www.aspfaq.com/show.asp?id=212 6
set oRSc=Server.Cre ateObject("ADOD B.Recordset")
oRSc.Open cSQLstr, oConn
Response.Conten tType = "text/plain"
Dim i, j, tmp
If Not oRSc.EOF Then*********** *************** *************** For i = 1 To oRSc.Fields.Cou nt
objTextFile.Wri te oRSc.Fields(i-1).Name
If i < oRSc.Fields.Cou nt Then
objTextFile.Wri te " "
End If
Next*********** *************** **************

As I said above, if you don't want the field names, don't write them. You
are in control of what is written. Just remove this loop.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jan 26 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4845
by: Karzy | last post by:
I would like to have a form that gives the user choices for selection parameters for email, printing etc. A real simple example: Give me all ______ who ______ when _______ where _______ I can figure this out if all of the selections are filled, but NOT if they just decide to use only one of the selection choices.
8
3173
by: Perre Van Wilrijk | last post by:
Hello, I have 2 ways of updating data I'm using often 1) via a cursor on TABLE1 update fields in TABLE2 2) via an some of variables ... SELECT @var1=FLD1, @var2=FLD2 FROM TABLE1 WHERE FLD-ID = @inputVAR UPDATE TABLE2 SET FLDx = @var1, FLDy = @var2
7
11896
by: CharlesEF | last post by:
Hi All, I have run into another problem that is eating my lunch. Should be simple but I am having one heck of a time. Please look at this SELECT statement: SELECT FROM States WHERE ] = "US"; is the SQL column name (because it sarts with 2?). As the statement is shown I get the error message: Unclosed quotation mark before the...
2
5258
by: phpuser32423 | last post by:
Hi everyone Is it by any chance possible to use mysql and php to auto create the content for drop-down lists on forms by retrieving the values from a database? The reason i ask is that on a site i am making i am asking users to select from list (e.g. nationality) however i would like to avoid typing out every possible value of which there...
3
6436
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I COULD be wrong... :) I've tried the access group...twice...and all I get is "Access doesn't like ".", which I know, or that my query names are too...
5
2817
by: freddy | last post by:
I have a select statement like this: string Select = "Select TableofContents, DataOwner, Delegates From NYC"; and it work fine, but if I was to put a space in like this: string Select = "Select Table of Contents, Data Owner, Delegates From NYC"; I would get an error in my da.fill(ds); Why can I not use a space in my select statement. I...
6
4829
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID SalesManName AT Alan Time
5
12303
by: OldBirdman | last post by:
I am attempting to assign a .RowSource to a ListBox using an SQL statement. I want to build the SQL statement "On-the-Fly", based on values in several controls on the form. I would like to restrict this discussion to Native Access, because when these discussions get beyond this, I don't understand, I cannot make them work, or I don't have the...
4
7768
by: hapnendad | last post by:
In the question statement below Field names are in and variables are in (). All fields referenced are in what I have named the ‘PAR’ Table. Using MS Access 2003, I am working on a project management database and have reached the point where I need to develop a way for managers to re-assign responsibility for all active projects to another of...
0
7620
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6172
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5452
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3571
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1154
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
861
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.