[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

StringBuilder in ASP.net vs Classic ASP

Posted on 2015-02-05
5
Medium Priority
?
302 Views
Last Modified: 2015-02-17
Hello

I'm attempting to write a routine that loops trough all the fields from one column of a database and write out a XML
I got a friend who helped me write some pseudo-code in asp.net, but I can't find how to run this in classic asp.

Any help/suggestions? here is the code:
 
Sub PrepareDataForQFE()
Dim strXML as StringBuilder
{You can set up the XML as a string builder that you manually create or as an XML document – your choice, but for this example, a simple string builder can work}
 
Dim dtTable as DataTable
dtTable = {your query results – obviously you have to run your query}
 
Dim drRow as DataRow
 
For Each drRow in dtTable
     Dim dcCol as DataColumn
 
     For Each dcCol in drRow
           strXML.Add(WriteXML(drCol.ColumnName, drCol.{Value}, {Attributes}))
     Next
Next
 
Result = QFEBridge.CallQuik(FormIDList, strXML.ToString, etc.)
 
End Sub
 
Function WriteXML(strColumnName, strValue, blnReadOnly, strFormat, etc.)
     {This function would write out the field part of the XML}
End Function
0
Comment
Question by:amucinobluedot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
ChloesDad earned 1336 total points
ID: 40592321
As there is no stringbuilder in classic asp you need to use a string

Replace these lines

dim strxml as stringbuilder
with
Dim xmlstr as string

and

 strXML.Add(WriteXML(drCol.ColumnName, drCol.{Value}, {Attributes}))
with
 strxml = strxml & WriteXML(drCol.ColumnName, drCol.{Value}, {Attributes})

finally

Result = QFEBridge.CallQuik(FormIDList, strXML.ToString, etc.)
with
Result = QFEBridge.CallQuik(FormIDList, strXML, etc.)
0
 

Author Comment

by:amucinobluedot
ID: 40592549
Thank you, This would work for all the values? I have 200 fields on the database and some are extensive (for example, addresses).

Would this hold?
0
 
LVL 15

Assisted Solution

by:ChloesDad
ChloesDad earned 1336 total points
ID: 40592648
As long as the rest of the code supplied is correct, all I have done is replace the stringbuilder in your supplied code with the correct string variable commands, i.e using & to append strings as opposed to the stringbuilder.add method.
0
 

Author Comment

by:amucinobluedot
ID: 40592756
I found some weird mistakes... looks like classic ASP does not accept the "as string"

Microsoft VBScript compilation error '800a0401'
Expected end of statement
/......../page.asp, line 297
Dim strXML As String
-----------------^


Fixed it by removing all the "as", the code ended as follows:

Sub PrepareDataForQFE()
Dim strXML

Dim dtTable
dtTable = rs_usermap

Dim drRow

For Each drRow in dtTable
     Dim dcCol

     For Each dcCol in drRow
           strxml = strxml & WriteXML(drCol.ColumnName, drCol.Fields.Item("QFField"), "&")
     Next
Next
Result = QFEBridge.CallQuik(FormIDList, strXML)
End Sub


Function WriteXML(strColumnName, strValue, blnReadOnly, strFormat)
End Function
0
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 664 total points
ID: 40593962
as you discovered, there are no data types in classic asp, that's why the statement

dim strXML as string

failed. all variables declared in classic asp are variants, meaning they can be whatever data type you want. you'll also find there are no DataTables in classic asp, instead you'll use a recordset, since you're getting data from a database. so, assuming your recordset has data in it, your code would look like:

Sub PrepareDataForQFE()
Dim strXML, rsData
 
set rs.Execute( "select data from table where conditions = true" )
 
if not rs.BOF and not rs.EOF then    '-- data has been returned 
     for each row in rsData
         for each col in row.Fields
             strXML = strXML & WriteXML( col.Value )
          next
    next
end if 

Result = QFEBridge.CallQuik(FormIDList, strXML.ToString, etc.)
 
End Sub

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question