Quotes in Variables - into textboxes...

Results 1 to 5 of 5

Thread: Quotes in Variables - into textboxes...

  1. #1
    Mike Pattimore Guest

    Default Quotes in Variables - into textboxes...

    I have tried to insert variables into textboxes that contain quotes, whilst I am aware that I can use the replace function to replace the queotes with double quotes the double quotes cancels the remainder of the variable from appearing. I f I remove the quotes around the actual variable in the textbox tag then the correct data appears until there is a space in the data, then nothing appears until after the space!!<BR><BR>Please help<BR><BR>Mike

  2. #2
    Join Date
    Dec 1969

    Default Not sure if this will work

    But have you tried using &quot; instead?<BR><BR> - Jeff

  3. #3
    Mike Pattimore Guest

    Default RE: Not sure if this will work

    Yeh The problem is still the same - I take it that was two single quotes?

  4. #4
    Join Date
    Dec 1969
    Los Angeles, CA

    Default RE: Quotes in Variables - into textboxes...

    Are you saying that replacing a &#039 with two &#039 does not work when you insert into the DB

  5. #5
    RipCat Guest

    Default More Than You Asked...But...

    If using stored procedures...I have found that you can use a command object and just add the parameters via the append method...Here&#039s an example...Be sure your parameter order matches your stored procedure...<BR><BR>Const adParamInput = &H0001<BR>Const adParamReturnValue = &H0004<BR>Const adInteger = 3<BR>Const adChar = 129<BR><BR>Constants from adoVBS.INC...<BR><BR>Set ocmCustomerMasterSave = Server.CreateObject("ADODB.Command")<BR><BR>ocmCus tomerMasterSave.ActiveConnection = "some connection"<BR> <BR>ocmCustomerMasterSave.CommandType = 4<BR><BR>ocmCustomerMasterSave.CommandText = "Stored Procedure NameWithSpaceAfterJustLikeThis " <BR> <BR>ocmCustomerMasterSave.Parameters.Append _<BR> ocmCustomerMasterSave.CreateParameter("ReturnValue ", adInteger, adParamReturnValue, 4)<BR><BR>ocmCustomerMasterSave.Parameters.Append _<BR> ocmCustomerMasterSave.CreateParameter("Description ", _<BR> adChar, adParamInput, 75, Trim(Request.Form("txtCustomerDescription")))<BR>< BR>ocmCustomerMasterSave.Execute<BR><BR>lcCustomer MasterId = ocmCustomerMasterSave.Parameters("ReturnValue").va lue<BR><BR>Set ocmCustomerMasterSave = Nothing<BR><BR>Not only do you not have to worry about embedded quotes using this...This is the only way I could get a return value from a stored procedure...Be sure to have your stored proc return line return appropriate value if you need one...If not, just don&#039t append the return parameter...<BR><BR>A VERY important point...If you are using append method of command object...You DON&#039T have to fix single quotes...If you are passing a string of values to stored procedure...You DO have to fix single quotes...<BR><BR>If you are using inline SQL statements...Here&#039s my function to replace...<BR><BR>lcData = SingleQuoteSql(Request.Form("element"))<BR><BR>&#0 60;%<BR><BR>Private Function SingleQuoteSql(tcString)<BR><BR>Dim lcReturnString<BR><BR>lcReturnString = ""<BR><BR>lcReturnString = Replace(tcString,"&#039","&#039&#039")<BR><BR>Sing leQuoteSql = lcReturnString<BR><BR>End Function<BR><BR>%&#062;<BR><BR>Hope this helps...<BR><BR>RipCat

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts