1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Write HTML code to database

Discussion in 'C#' started by Zoro, Jul 12, 2010.

  1. #1
    I'm using C# Net and MySQL
    Is there function or someting to write html code to MySQL database?
    I'm using MySQL Connector/Net dll file.
    Comunication with database is via SQL strings.

    I think the problems are those stupid characters in html....

    Thanks on your time...
     
    Zoro, Jul 12, 2010 IP
  2. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    The only reason that I could think of that it wouldn't write to database is because of the quotes (" ") within the HTML. If it is simple HTML, with no javascript, the easiest way would be to replace these with single quotes (' ') before you execute the SQL statement. This will not work if you have html like: <a href="javascript:myFunction('1')">
     
    camjohnson95, Jul 15, 2010 IP
  3. Zoro

    Zoro Active Member

    Messages:
    167
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #3
    tnx on reply...
    string.format() works perfect :)
     
    Zoro, Jul 16, 2010 IP
  4. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #4
    But be aware that you need to be careful of SQL injection when running SQL queries in this manner. If this page is going to be available publicly, especially if it is a commercial page, then you need to use another method to add items to the database.
     
    camjohnson95, Jul 17, 2010 IP
  5. xpertprogrammer

    xpertprogrammer Peon

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    above solution is correct
     
    xpertprogrammer, Jul 18, 2010 IP
  6. urstop

    urstop Peon

    Messages:
    224
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Used command parameters and just assign the HTML string variable to the parameter, that way you dont have to worry about the quotes or special characters.
     
    urstop, Jul 18, 2010 IP
  7. chanda

    chanda Peon

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i dont know about the mysql but i will suggest to use sql server 2000 or 2005,,,
     
    chanda, Aug 19, 2010 IP
  8. longcall911

    longcall911 Peon

    Messages:
    1,672
    Likes Received:
    87
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You can put any html in the SQL database when you make the field a text field. If you are putting URLs in the field, use single quotes as suggested above. But for the most part use as little formatting as possible. Do your formatting with CSS.
     
    longcall911, Aug 19, 2010 IP
  9. susasl

    susasl Active Member

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #9
    You should add ValidateRequest="false" page directive <%@ Page ValidateRequest="false" Title="XX" %>
     
    susasl, Aug 28, 2010 IP