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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with ' 2

Status
Not open for further replies.

Gatorajc

MIS
Mar 1, 2002
423
US
Anyone have the line of code to allow you to put in a ' into a database without erroring out. I seem to have misplaced mine.


AJ
[americanflag]


 
thread333-600736
Replace(MyString, "'", "''")

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
' To replace ' in sql with ''
Private Function fix(x)
x = "" & x
if x<>&quot;&quot; then
fix = Replace(x, &quot;'&quot;, &quot;''&quot;)
else
fix = x
end if
End Function

-Volkoff007
 
sqlString = &quot;INSERT INTO dailydata (Dte,tblDept_DeptID,TotDeptFte)&quot;
sqlString = sqlString & &quot; VALUES ('&quot; & datefield & &quot;','&quot; & department & &quot;','&quot; & totftescheduled & &quot;')&quot;

For some reason I can not get it to work
I either get a SQL syntax error or

Cannot use parentheses when calling a Sub

/HTMLpages/Web_Projects/AccountablityReport/enterdata3.asp, line 35

Replace(sqlString, &quot;'&quot;, &quot;''&quot;)




AJ
[americanflag]


 
Note: Generally defining a function called fix is not a good idea since tere is already a built-in function called fix. I'm not to sure what effect this will have, but even if it works it will probably hurt efficiency as the system attempts to figure out which fix to use. If it uses scope of declaration to decide than you have lost the use of the built-in fix function since you have redeclard it.

Of course if you were using python... ;)

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
minilogo.gif alt=tiernok.com
The never-completed website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top