[thelist] Freebie ASP Tip: Getstring & SQL Concatenation

Scott Dexter sgd at ti3.com
Thu, 23 Dec 1999 00:31:31 -0600


exellent tip!

here's the SQL Server version of the select statement, and as a bonus,
making everything into one field:

> "SELECT FirstName + ' ' + LastName + ', ' + Title + '<BR>' AS
NameTitleList From Authors"

and you can scroll through it like any other recordset you're worked with
instead of the fancy-schmancy GetString --which may have to since GetString
is part of ADO 2.5 Beta, and you might not have that installed...

 ...or your GetString looks like this:

Set myStr = objRS.GetString(,,"",,"&nbsp;")


Quick GetString reference:

Set var = recordset.GetString(StringFormat, NumRows, ColumnDelimiter,
RowDelimiter, NullExpr)

StringFormat
	 is optional, default is 2 (adClipString)
NumRows
	 is optional, the number of rows in the recordset to convert (if
greater than the actual number available, you get the whole recordset
converted)
ColumnDelimiter
	optional; the text you want between fields (default is a tab, I
replaced it above with the empty string)
RowDelimiter
	optional; the text you want between rows (default is a carriage
return, i took the default above)
NullExpr
	optional; the text you want in place of a Null value (default is the
empty string: "")


fun fun fun
sgd
--
think safely

> -----Original Message-----
> From: Eric Engelmann [mailto:eric@geonetric.com]

> Normally, with Getstring, you can only specify a character(s) between
> *every* field, not just between fields two and three. If you 
> used this:
> 
> myStr = objRS.GetString(,,", ","<br>","&nbsp;")
> 
> You'd get
> 
> FirstName, LastName, Title<br>
> 
> However, you can use SQL to concatenate FirstName and 
> LastName into one
> field, like this:
> 
> "SELECT FirstName & " " & LastName AS FullName,Title From Authors"
>