|
 |
asp_databases thread: Apostrophe
Message #1 by "Junaid hasan" <jnd_hsn@h...> on Thu, 25 Jan 2001 15:11:41 -0600
|
|
Hey Guru's
Here's my problem
I have written a normal store procedure to insert the data into database.
iam calling the procedure in the asp page and iam passing all the values
as parameters.Every thing is working fine until any charecter field inserts
(Apostrophe) Like ('). Its breaking the code its failing where it reaches
Apostrophe charecter.
here is my Eg:
conn.Execute ("AR_sp_UpdateSchool '" & sProviderName & "', "_
& sContactName & ", '"_
& sContactName & "', '"_
& sTelephoneNum & "', '"_
& sExt & "', '"_
& sAddress1 & "', '"_
& sAdress2 & "', '"_
& sCity & "', '"_
& sState & "', '"_
& sZipCode & "', '"_
& sDateAdded & "', '"_
& sAddBy & "', "_
& sStatus &","_
& sID)
If sProviderName got Apostrophe it fails
Any help will be Appreciated
>From: "Harsh Nandu" <harsh_stgil@h...>
>Reply-To: "How To" <proasp_howto@p...>
>To: "How To" <proasp_howto@p...>
>Subject: RE: ListBox and TextField
>Date: Fri, 08 Dec 2000 09:18:49 -0000
>
>Check the code below.
>I hope it will solve your problem.
>It works for both IE & Netscape.
>------------------------------------------------------------------------
>
>
><HTML>
><HEAD>
><TITLE>Client Query</TITLE>
>
><Script Language="javascript">
><!--
>function Fn_Get_Det(i)
>{
> var val=""
> val=document.frmAddSch.selClientDispId.options[document.frmAddSch.selClientDispId.selectedIndex].value;
> document.frmAddSch.txtClientId.value=val.substr(0,val.search(':'));
> val=val.substr(val.search(':')+1);
> document.frmAddSch.txtClientNm.value=val.substr(0,val.search(':'));
> document.frmAddSch.txtComm.value=val.substr(val.search(':')+1);
> return;
>}
>
>//-->
></SCRIPT>
>
></HEAD>
><BODY bgColor=papayawhip text="maroon" topmargin="0" rightmargin="0"
>marginheight="0" marginwidth="0">
>
> <form name="frmAddSch" method="post" action="ScheduleMaster.asp"
>onsubmit="return isValid();">
>
> <TABLE border=1 width="100%">
>
> <TR>
> <TD align="middle">
> <!-- The drop down list populated from the previous recordset under
>discussion-->
> <Select name="selClientDispId" onchange="Fn_Get_Det(0)" >
> <Option value="::" selected></Option>
>
> <!-- The value for the option is a concatenated string of Client
>id,Client
>NAme &
> Factor Commission for the client. This String is seperated by
>Fn_Get_Det()
> to get individual Values -->
> <option value="2:REFACTORINGNONLENDING:1">PHANI</option>
>
> <!-- The value for the option is a concatenated string of Client
>id,Client
>NAme &
> Factor Commission for the client. This String is seperated by
>Fn_Get_Det()
> to get individual Values -->
> <option value="4:FG:9999999999999999.99">GHJH</option>
>
> <!-- The value for the option is a concatenated string of Client
>id,Client
>NAme &
> Factor Commission for the client. This String is seperated by
>Fn_Get_Det()
> to get individual Values -->
> <option value="7:JHFDSAJH:9999999999999999.99">00909030</option>
>
> </Select>
> <INPUT name="txtClientId" >
> <INPUT name="txtClientNm" >
> <INPUT name="txtComm">
> </TD>
> </TR>
> </TABLE>
><table width=100%><tr>
><td align=center>
><input type=submit name="cmdMore" Value="More">
><input type=submit name="cmdSubmit" Value="Submit">
><input type=reset name="Reset" Value="Reset"></td>
></tr></table>
></td></tr>
></Table>
></form>
>
>---<BR>
>MaximumASP offers enhanced hosting solutions on the Windows 2000 platform.
>Dedicated processor, RAM, and server resources provide dedicated server
>performance at virtual server prices. Commercial components provided;
>custom components allowed.<BR>
>---<BR>
>You are currently subscribed to proasp_howto as: jnd_hsn@h...<BR>
>$subst('Email.Unsub')<BR>
>
></BODY>
>
></HTML>
>
>
>
>------------------------------------------------------------------------
>
>
>>From: "Manikandan R" <manikandanr@c...>
>>Reply-To: "How To" <proasp_howto@p...>
>>To: "How To" <proasp_howto@p...>
>>Subject: RE: ListBox and TextField
>>Date: Thu, 7 Dec 2000 16:58:02 +0800
>>
>>If you want to display the value immediatly when the user selects a value
>>from the listbox then go for client side javascript. somethinglike this
>>
>><script language=javascript>
>>OnSelectChange(){
>>
>> frm1.text1.value = frm1.listbox1.value;
>>}
>><script>
>>
>><form name=frm1>
>><select onChange="onSelectChange()" name=listbox1> <option value=one> one
>></option> .... </select>
>><input type=text name=txt1>
>></form>
>>
>>
>>Note: this DOM is based on IE, if you want this to work on NS then use
>>proper DOM. like Document.frm1.text1.value etc..
>>
>>Mani.
>>
>>-----Original Message-----
>>From: Kings Lee [mailto:kings0909@y...]
>>Sent: Thursday, December 07, 2000 3:12 PM
>>To: How To
>>Subject: ListBox and TextField
>>
>>
>>I have one ListBox and three textfield, I am trying to display the data
>>in the textfield when I make a selection in the ListBox. The listbox only
>>contain the id, and all of the fields belong to the same table. I am
>>trying to put everything in an array first and call it back when I make a
>>selection.
>>Can anyone help me on this one??
>>Thanks alot.
>>Or if anyone know if there is similar example on the web.
>>
>>
>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
Message #2 by Imar Spaanjaars <Imar@S...> on Fri, 26 Jan 2001 00:14:46 +0100
|
|
Replace the apostrophe with two apostrophes, before you pass the variable
to the stored procedure. Use Replace to accomplish that:
Example:
Dim sProviderName
sProviderName = "Bla bla with an ' and bla bla"
sProviderName = Replace(sProviderName, "'", "''")
' (Now sProviderName = "Bla bla with an '' and bla bla"
Now the procedure will be processed normally. Note that the double
apostrophe is just to make the SQL work: the database will only contain one
apostrophe.
HtH
Imar
At 11:12 PM 1/25/2001 -0800, you wrote:
>Hey Guru's
>
>Here's my problem
>
>I have written a normal store procedure to insert the data into database.
>iam calling the procedure in the asp page and iam passing all the values
>as parameters.Every thing is working fine until any charecter field inserts
>(Apostrophe) Like ('). Its breaking the code its failing where it reaches
>Apostrophe charecter.
>here is my Eg:
>
>
>conn.Execute ("AR_sp_UpdateSchool '" & sProviderName & "', "_
>
>& sContactName & ", '"_
>
>& sContactName & "', '"_
>
>& sTelephoneNum & "', '"_
>
>& sExt & "', '"_
>
>& sAddress1 & "', '"_
>
>& sAdress2 & "', '"_
>
>& sCity & "', '"_
>
>& sState & "', '"_
>
>& sZipCode & "', '"_
>
>& sDateAdded & "', '"_
>
>& sAddBy & "', "_
>
>& sStatus &","_
>
>& sID)
>
>
>If sProviderName got Apostrophe it fails
>Any help will be Appreciated
Message #3 by John Pirkey <mailjohnny101@y...> on Thu, 25 Jan 2001 16:59:40 -0800 (PST)
|
|
you have to replace those nasty little ticks with either, an empty space or two of
them:
sProviderName = Replace(sProviderName, "'", "''")
replace is available with VBscript version 5 and above. most everyone has it now.
having two tick marks tells the database that you want to include the tick in the
data and thats it's not marking the end of the string data.
hope this helps,
john
--- Junaid hasan <jnd_hsn@h...> wrote:
>
> Hey Guru's
>
> Here's my problem
>
> I have written a normal store procedure to insert the data into database.
> iam calling the procedure in the asp page and iam passing all the values
> as parameters.Every thing is working fine until any charecter field inserts
> (Apostrophe) Like ('). Its breaking the code its failing where it reaches
> Apostrophe charecter.
> here is my Eg:
>
>
> conn.Execute ("AR_sp_UpdateSchool '" & sProviderName & "', "_
> & sContactName & ", '"_
> & sContactName & "', '"_
> & sTelephoneNum & "', '"_
> & sExt & "', '"_
> & sAddress1 & "', '"_
> & sAdress2 & "', '"_
> & sCity & "', '"_
> & sState & "', '"_
> & sZipCode & "', '"_
> & sDateAdded & "', '"_
> & sAddBy & "', "_
> & sStatus &","_
> & sID)
>
>
> If sProviderName got Apostrophe it fails
> Any help will be Appreciated
=====
----------------------------
John Pirkey
MCSD
John@S...
http://www.stlvbug.org
Message #4 by "Wally Burfine" <oopconsultant@h...> on Fri, 26 Jan 2001 04:23:47 -0000
|
|
Change single apostrophes to 2 single apostrophes:
replace(str,"'","''")
>From: "Junaid hasan" <jnd_hsn@h...>
>Reply-To: "ASP Databases" <asp_databases@p...>
>To: "ASP Databases" <asp_databases@p...>
>Subject: [asp_databases] Apostrophe
>Date: Thu, 25 Jan 2001 23:12:33 -0800
>
>Hey Guru's
>
>Here's my problem
>
>I have written a normal store procedure to insert the data into database.
>iam calling the procedure in the asp page and iam passing all the values
>as parameters.Every thing is working fine until any charecter field inserts
>(Apostrophe) Like ('). Its breaking the code its failing where it reaches
>Apostrophe charecter.
>here is my Eg:
>
>
>conn.Execute ("AR_sp_UpdateSchool '" & sProviderName & "', "_
> & sContactName & ", '"_
> & sContactName & "', '"_
> & sTelephoneNum & "', '"_
> & sExt & "', '"_
> & sAddress1 & "', '"_
> & sAdress2 & "', '"_
> & sCity & "', '"_
> & sState & "', '"_
> & sZipCode & "', '"_
> & sDateAdded & "', '"_
> & sAddBy & "', "_
> & sStatus &","_
> & sID)
>
>
>If sProviderName got Apostrophe it fails
>Any help will be Appreciated
>
> >From: "Harsh Nandu" <harsh_stgil@h...>
> >Reply-To: "How To" <proasp_howto@p...>
> >To: "How To" <proasp_howto@p...>
> >Subject: RE: ListBox and TextField
> >Date: Fri, 08 Dec 2000 09:18:49 -0000
> >
> >Check the code below.
> >I hope it will solve your problem.
> >It works for both IE & Netscape.
> >------------------------------------------------------------------------
> >
> >
> ><HTML>
> ><HEAD>
> ><TITLE>Client Query</TITLE>
> >
> ><Script Language="javascript">
> ><!--
> >function Fn_Get_Det(i)
> >{
> > var val=""
> > val=document.frmAddSch.selClientDispId.options[document.frmAddSch.selClientDispId.selectedIndex].value;
> > document.frmAddSch.txtClientId.value=val.substr(0,val.search(':'));
> > val=val.substr(val.search(':')+1);
> > document.frmAddSch.txtClientNm.value=val.substr(0,val.search(':'));
> > document.frmAddSch.txtComm.value=val.substr(val.search(':')+1);
> > return;
> >}
> >
> >//-->
> ></SCRIPT>
> >
> ></HEAD>
> ><BODY bgColor=papayawhip text="maroon" topmargin="0" rightmargin="0"
> >marginheight="0" marginwidth="0">
> >
> > <form name="frmAddSch" method="post" action="ScheduleMaster.asp"
> >onsubmit="return isValid();">
> >
> > <TABLE border=1 width="100%">
> >
> > <TR>
> > <TD align="middle">
> > <!-- The drop down list populated from the previous recordset under
> >discussion-->
> > <Select name="selClientDispId" onchange="Fn_Get_Det(0)" >
> > <Option value="::" selected></Option>
> >
> > <!-- The value for the option is a concatenated string of Client
> >id,Client
> >NAme &
> > Factor Commission for the client. This String is seperated by
> >Fn_Get_Det()
> > to get individual Values -->
> > <option value="2:REFACTORINGNONLENDING:1">PHANI</option>
> >
> > <!-- The value for the option is a concatenated string of Client
> >id,Client
> >NAme &
> > Factor Commission for the client. This String is seperated by
> >Fn_Get_Det()
> > to get individual Values -->
> > <option value="4:FG:9999999999999999.99">GHJH</option>
> >
> > <!-- The value for the option is a concatenated string of Client
> >id,Client
> >NAme &
> > Factor Commission for the client. This String is seperated by
> >Fn_Get_Det()
> > to get individual Values -->
> > <option value="7:JHFDSAJH:9999999999999999.99">00909030</option>
> >
> > </Select>
> > <INPUT name="txtClientId" >
> > <INPUT name="txtClientNm" >
> > <INPUT name="txtComm">
> > </TD>
> > </TR>
> > </TABLE>
> ><table width=100%><tr>
> ><td align=center>
> ><input type=submit name="cmdMore" Value="More">
> ><input type=submit name="cmdSubmit" Value="Submit">
> ><input type=reset name="Reset" Value="Reset"></td>
> ></tr></table>
> ></td></tr>
> ></Table>
> ></form>
> >
> >---<BR>
> >MaximumASP offers enhanced hosting solutions on the Windows 2000
>platform.
> >Dedicated processor, RAM, and server resources provide dedicated server
> >performance at virtual server prices. Commercial components provided;
> >custom components allowed.<BR>
> >---<BR>
> >You are currently subscribed to proasp_howto as: jnd_hsn@h...<BR>
> >$subst('Email.Unsub')<BR>
> >
> ></BODY>
> >
> ></HTML>
> >
> >
> >
> >------------------------------------------------------------------------
> >
> >
> >>From: "Manikandan R" <manikandanr@c...>
> >>Reply-To: "How To" <proasp_howto@p...>
> >>To: "How To" <proasp_howto@p...>
> >>Subject: RE: ListBox and TextField
> >>Date: Thu, 7 Dec 2000 16:58:02 +0800
> >>
> >>If you want to display the value immediatly when the user selects a
>value
> >>from the listbox then go for client side javascript. somethinglike this
> >>
> >><script language=javascript>
> >>OnSelectChange(){
> >>
> >> frm1.text1.value = frm1.listbox1.value;
> >>}
> >><script>
> >>
> >><form name=frm1>
> >><select onChange="onSelectChange()" name=listbox1> <option value=one>
>one
> >></option> .... </select>
> >><input type=text name=txt1>
> >></form>
> >>
> >>
> >>Note: this DOM is based on IE, if you want this to work on NS then use
> >>proper DOM. like Document.frm1.text1.value etc..
> >>
> >>Mani.
> >>
> >>-----Original Message-----
> >>From: Kings Lee [mailto:kings0909@y...]
> >>Sent: Thursday, December 07, 2000 3:12 PM
> >>To: How To
> >>Subject: ListBox and TextField
> >>
> >>
> >>I have one ListBox and three textfield, I am trying to display the data
> >>in the textfield when I make a selection in the ListBox. The listbox
>only
> >>contain the id, and all of the fields belong to the same table. I am
> >>trying to put everything in an array first and call it back when I make
>a
> >>selection.
> >>Can anyone help me on this one??
> >>Thanks alot.
> >>Or if anyone know if there is similar example on the web.
Message #5 by "Junaid hasan" <jnd_hsn@h...> on Fri, 26 Jan 2001 08:12:36 -0600
|
|
Thanks Imar,
It works good i really appreciate it.
junaid
>From: Imar Spaanjaars <Imar@S...>
>Reply-To: "ASP Databases" <asp_databases@p...>
>To: "ASP Databases" <asp_databases@p...>
>Subject: [asp_databases] Re: Apostrophe
>Date: Fri, 26 Jan 2001 00:14:46 +0100
>
>Replace the apostrophe with two apostrophes, before you pass the variable
>to the stored procedure. Use Replace to accomplish that:
>
>Example:
>
>Dim sProviderName
>sProviderName = "Bla bla with an ' and bla bla"
>sProviderName = Replace(sProviderName, "'", "''")
>' (Now sProviderName = "Bla bla with an '' and bla bla"
>
>Now the procedure will be processed normally. Note that the double
>apostrophe is just to make the SQL work: the database will only contain one
>apostrophe.
>
>HtH
>
>Imar
>
>
>At 11:12 PM 1/25/2001 -0800, you wrote:
>
>>Hey Guru's
>>
>>Here's my problem
>>
>>I have written a normal store procedure to insert the data into database.
>>iam calling the procedure in the asp page and iam passing all the values
>>as parameters.Every thing is working fine until any charecter field
>>inserts
>>(Apostrophe) Like ('). Its breaking the code its failing where it reaches
>>Apostrophe charecter.
>>here is my Eg:
>>
>>
>>conn.Execute ("AR_sp_UpdateSchool '" & sProviderName & "', "_
>>
>>& sContactName & ", '"_
>>
>>& sContactName & "', '"_
>>
>>& sTelephoneNum & "', '"_
>>
>>& sExt & "', '"_
>>
>>& sAddress1 & "', '"_
>>
>>& sAdress2 & "', '"_
>>
>>& sCity & "', '"_
>>
>>& sState & "', '"_
>>
>>& sZipCode & "', '"_
>>
>>& sDateAdded & "', '"_
>>
>>& sAddBy & "', "_
>>
>>& sStatus &","_
>>
>>& sID)
>>
>>
>>If sProviderName got Apostrophe it fails
>>Any help will be Appreciated
>
>
|
|
 |