You are viewing limited content. For full access, please sign in.

Question

Question

Query SQL and write to an output file

asked on February 2, 2016

Hi,

 

I am trying to right a script ( Very new to Scripting ) that will query a SQL database, Return a certain number of rows and then right them to an output file, In this case CSV.

 

I can do this for a single entry without any problems, what i am having trouble with is trying to loop through all the rows, and then writing all the rows to the csv.

 

what i have written so far is as follows :-

 


        Dim csvWriter As New System.IO.StreamWriter("c:\test.csv",true)
        Dim dataRow As String 
        Dim csvData As New StringBuilder  
    
        Dim Result() As String
        Result = me.GetTokenValue("ForEachRow_Iteration")

        Dim InterationValue As String
        InterationValue = me.GetTokenValue("Token_Iteration")

 

 

Dim Result() As String
        Result = me.GetTokenValue("ForEachRow_Iteration")

        Dim InterationValue As String
        InterationValue = me.GetTokenValue("Token_Iteration")  ----- Token assigned in workflow from each row

        For Each InterationValue in Result


        dataRow = me.TokenReplace( "%(Token_Date),%(Token_ID),%(Token_TYPE),%(Token_Document), %(Token_Category)")   ---- tokens assigned from each entry
       

        csvData.AppendLine(dataRow)
        Next

 

 

Can Anyone See what i am doing wrong?

 

Hope someone can help

 

Regards

 

Mark

0 0

Answer

SELECTED ANSWER
replied on February 2, 2016 Show version history

this thread might be very helpful:

 

http://answers.laserfiche.com/questions/77293/How-to-export-multivalue-token-into-csv-file

 

You can get all of your data into a multivalue token using workflow, then simplify the writing to CSV by using that. 

1 0

Replies

replied on February 3, 2016

Thanks Chris,

 

This article is greate juts what i was looking for, still have an issue that i posted there but thanks for you help

 

Regards

 

mark

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.