Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getString() 1

Status
Not open for further replies.

xjs

Programmer
Apr 4, 2002
21
US
i want to use getString() to optimize code. i have "WHERE" and "ORDER BY" in my SQL statment but don't want those fields to display on my table.

strSQL = SELECT FIELD1, FIELD2 WHERE FIELD3='something' ORDER BY FIELD4"

i want to display only FIELD1 and FIELD2 in a table using getString() on my ASP page. can this be done?

any help is appreciated, thanks.
 
Perhaps I am just being simple-minded (or tired, whichever is more applicable at the moment), but are you not just returning the first two fields (Field1, Field2) in your recordset to begin with? If so, then why would you be concerned about the other two?

Also, should not your SQL have a FROM clause? Or maybe I have just never written quite that way and am unfamiliar with the result set... Or I have completely misunderstood your question in which case I apologise and humbly ask you rephrase

-----------------------------------------------------------------------------------------------------
"If you can't explain something to a six-year-old, you really don't understand it yourself."
-- Albert Einstein
 
i wrote a bad SQL statement above. let me make this clear. i only want FIELD1 and FIELD2 in my recordset so i write the SQL to select only FIELD1 and FIELD2 as shown below but get an error because i have a WHERE and ORDER BY that needs FIELD3 and FIELD4 respectively.

strSQL = SELECT FIELD1, FIELD2 FROM TABLE WHERE FIELD3='something' ORDER BY FIELD4"

for the query to work the SELECT must also include FIELD3 and FIELD4.

strSQL = SELECT FIELD1, FIELD2, FIELD3, FIELD4 FROM TABLE WHERE FIELD3='something' ORDER BY FIELD4"

using getString() with this query will give me all 4 fields when i only want FIELD1 and FIELD2. is there a way to do this?
 
You could always switch to the GetRows() Function. This will return the data in an array for you.

Here's more info on the recordset object (GetRows and GetString are down in the methods section).


-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
tarwn, i haven't tried i your suggestion yet but it looks like its exactly what i was looking for. thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top