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!

how to permanently remove apostrophe

Status
Not open for further replies.

Chrisma

Programmer
Feb 6, 2006
15
AU
help me again guys, I am only new in ASP world and my knowledge is not so broad.

I have a back end MS Access. I need to remove the apostrophe. i mean like this: ASP's .Net when I add this i got a syntax error.

i don't know how to remove, replace or escape this before they passed to and from the database using web pages.


all the value with apostrophe I got syntax error.

please help me.






 
use the replace function...may the thread pointed by Chris already does that...here is an example...

Replace(yourfield,"'","''")

-DNG
 
thanks guys but i am still getting an error. after i replace the apostrophe and run the sql I get an

Error Type:
Microsoft VBScript runtime (0x800A0009)
Subscript out of range: '[number: 1]'

here is the code:
for the request form:

<td width="39%"><div align="center"><b>Branch: </b><i>(required)</i><b><br>
<select name="trainbranch" tabindex="5">
<option value="NOT_SELECTED" selected>Please Select
a School/Branch</option>
<% sql = "SELECT * FROM branch where branch <> '"&session ("branch")&"' ORDER BY branch"
rs.open sql, cn
if not rs.eof then
do until rs.eof
response.write "<option value='" & rs("branch") & "::" & rs("department_sk")&"'>" & rs("branch") & "</option>"
rs.movenext
loop
end if
rs.close
%>
</select>
</b><b> <br><br> </b></div></td>


To insert in the database
BranchArray = Split(trim(request.form("trainbranch")),"::")
branch = SchoolBranchArray(0)
department_sk = SchoolBranchArray(1)

For SQL code:

sql = "Insert into Branch (STAFF_SK, COURSE_NAME, BRANCH, START_DATE, PROVIDER_NAME, FUND_SOURCE, HOURS, DIRECT_COSTS, ERT_COSTS, SCHOOL_COSTS, BRANCH_COSTS, DEPARTMENT_SK, PROGRAM_TYPE) " & _ "
VALUES ("&session("staffsk")&",'"&sqlsafe(course)&"','"&branch&"',#"&startdate&"#,"&provider&","&funding&")"
'response.write sql
rs.open sql, cn

please help.

 
maybe you should think about using option explicit

Code:
[red]BranchArray[/red] = Split(trim(request.form("trainbranch")),"::")
branch = [blue]SchoolBranchArray(0)[/blue]
department_sk = [blue]SchoolBranchArray(1)[/blue]




Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top