Howdy,
Dim reader As SqlDataReader = Command.ExecuteReader()
Dim oBuilder As New StringBuilder
While reader.Read()
For i As Integer = 0 To reader.FieldCount - 1
oBuilder.Append(reader(i))
oBuilder.Append("|")
Next
End While
--
Milosz
"Elmo Watson" wrote:
> Right now, I'm querying the database and using a DataReader to retrieve the
> fields, and save to a Pipe delimited text file
> However, it's a little cumbersome, in that I'm using the AppendFormat
> function of the stringBuilder to do it
> Kind of like this:
>
> While objDR.Read()
> oBuilder.AppendFormat(objDR("MerchantName").ToString.Trim)
> oBuilder.AppendFormat("|" & objDR("VendorID").ToString.Trim)
> oBuilder.AppendFormat("|" & objDR("TransactionDate").ToString.Trim)
> ' .....plus other columns in the database
> end While
> Then, I write the data to the file
>
> Is there a way I can format this in much fewer lines?
>
> For instance, in Classic ASP, when retrieving a Recordset, you could iterate
> through the fields, very simply, and format as you would wish.
> Is there something similar in ASP.Net which will allow me to do something
> like this, so that there would be less code?
>
>
>
|