inserting code into a db table

Results 1 to 3 of 3

Thread: inserting code into a db table

  1. #1
    Join Date
    Dec 1969

    Default inserting code into a db table

    hi, how can i do this without getting an error:<BR>sql = "insert into tablename(themessage) values(&#039;some asp code is here including some sql code&#039;)"<BR>like you have in your message board, if i would want to insert some code into this post it would be fine but when i try to insert some into my db, i get some kind of an error

  2. #2
    Join Date
    Dec 1969

    Default RE: inserting code into a db table

    Remember to put # before and after a date field variable, &#039; before and after a text field variable, and nothing before and after a number field variable.<BR><BR>DB FAQ: Syntax Error in SQL Statement <BR><BR>Must use single quotes instead of double quotes around text to be searched.<BR><BR>Best regards,<BR>-Paul<BR><BR> - Web Database Developer<BR><BR>Bullschmidt Bar Chart - Free ASP Bar Chart Tool<BR><BR><BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default ASPFAQs, category Database, Queries

    Oldest one in there:<BR><BR><BR><BR>*HOWEVER*<BR><BR>That probably won&#039;t be enough. You will probably *also* want to convert CR/LF characters into something else, too. Usually, they get converted into &lt;BR&#062;, to indicate the HTML equivalent of a new line.<BR><BR>SO...<BR><BR>&#060;%<BR>txt = Request("someTextArea")<BR>txt = Replace( txt, "&#039;", "&#039;&#039;" )<BR>txt = Replace( txt, vbCrLf, "&lt;BR&#062;" )<BR>... other replaces as needed ...<BR>SQL = "INSERT into table (fld1, ... ) VALUES(&#039;" & txt & "&#039;, ... )"<BR>...<BR>%&#062;<BR><BR>ALTERNATIVE: Use the ADODB.RecordSet.AddNew method to add the record to the DB. You should *not* then have to do those transformations.<BR><BR>

Posting Permissions

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