Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help calling function in ActiveX task

Status
Not open for further replies.

jpicks

MIS
Oct 11, 2002
158
US
using SQL Server 2000, SP3

Hi all,

I'm struggling with calling a function that I wrote within an ActiveX task. The ActiveX task parses a text file and then inserts the records into a table using ADO. I wrote a function that uses the replace function to replace a single apostrophe with two apostrophes, so that strings with apostrophes can be inserted into a table.


Funtion I am trying to call:
Code:
Function CleanseString(strFieldName)
 If InStr(1, strFieldName, "'") Then
    strFieldName = Replace(strFieldName,"'","''")
 End If
End Function

I am trying to call the function using the following code:
Code:
strField1 = Call CleanseString strField1

I'm hoping you guys can help point me in the right direction.

Thanks in advance,

Jim













 
strField1 = CleanseString(strField1)

or you couuld just do this without the function

strField1 = Replace(strField1,"'","''")


======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Thanks for the reply. I appreciate the help. That did the trick.

I decided to go with the function so that if I have to do any other manipulation to the strings that go into my insert statement, I can just add it to the function once, instead of dozens of times. I will be reusing the logic in this package to handle a large number of incoming files and I want to make it as robust as possible.

FYI - for other vbscript novices.
There was a bug in the function I wrote as well. The function should be:

Code:
Function CleanseString(strFieldName)
	 If InStr(1, strFieldName, "'") Then 
		strFieldName = Replace(strFieldName,"'","''")
	 End If
	 CleanseString = strFieldName
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top