Replace()

So:

Replace(rs.Fields(5), "&", "and")

Cheers
Ken

> -----Original Message-----
> From: Bryan Garmon [mailto:[EMAIL PROTECTED]
> Sent: Friday, 11 July 2008 9:29 PM
> To: NT System Admin Issues
> Subject: VBScript help replacing & character with the word And
>
> I have a VBScript that runs a SQL Stored procedure, and then using a If Then
> statement, the script loops through the results and uses WriteLine to output
> the results of the stored procedure into a text file.
>
> The problem I'm running into is that the text file created by this VBScript
> gets fed into an XML parsing engine that does not accept the "&" character.
>
> How can I tell the VBScript that if it finds the "&" character during the
> processing that it should replace it with the word "and"?
>
> Snippet from script:
>
> Rs.Open "Execute [master].[dbo].[sp_mystoredproc]",Con
> If Not Rs.EOF Then
> RS.MoveFirst
> tsBaseFile.WriteLine(" <s:AttributeType name=""c5"" rs:name=""Drive""
> rs:number=""6"" rs:keycolumn=""false"" mifAttrId='6'>")
> tsBaseFile.WriteLine(" <s:datatype dt:type=""string""
> dt:maxLength=""255""/>")
> tsBaseFile.WriteLine(" </s:AttributeType>")
> While Not rs.EOF
> Outstring = " <z:row" _
> & "c5=""" + Rs.Fields(5) + """" _
> & "/>"
> tsBaseFile.WriteLine(Outstring)
> Rs.MoveNext
> Wend
> Rs.Close
>
>
> The output of the text file for C5 looks like this:
>
> C5="My Data & Me"
>
> But I need it to read:
>
> C5="My Data and Me"
>
>
>
> ~ Upgrade to Next Generation Antispam/Antivirus with Ninja!    ~
> ~ <http://www.sunbelt-software.com/SunbeltMessagingNinja.cfm>  ~

~ Upgrade to Next Generation Antispam/Antivirus with Ninja!    ~
~ <http://www.sunbelt-software.com/SunbeltMessagingNinja.cfm>  ~

Reply via email to