Saving editor contains to a SQL database

Last post 06-18-2006, 11:33 PM by Adam. 1 replies.
Sort Posts: Previous Next
  •  06-17-2006, 2:45 PM 20235

    Saving editor contains to a SQL database

    Can’t save the editor contain to a SQL database, getting error(s) all the time.

    The connection string is correct. What happens is that editor’s html code sometimes makes an error when trying to save the editor contains.

    Saving standard text, no problems. But if I try to write complex html code in the editor (Editor in Normal mode, not HTML mode) and try to save I sometimes get errors.


    Any solution to fix this will “make my day”.

    Regards
    Rune


    Below is a copy of my ASP.NET 2005 code:

    Sub btn_save_html_code(ByVal sender As Object, ByVal e As System.EventArgs)

    Dim Post_ID As Integer

    Post_ID = Request.QueryString("ActionID")

    Dim strConnection As String = ConfigurationManager.ConnectionStrings("MydbConnectionString").ConnectionString

            Dim objConnection As New SqlConnection(strConnection)

            Dim strSQL As String = "UPDATE testdb" & _

                    " SET html_Code = '" & Editor1.Text & "'" & _

                    " WHERE db_ID = '" & Post_ID & "'"

            Dim dbComm As New SqlCommand(strSQL, objConnection)

            objConnection.Open()

            dbComm.ExecuteNonQuery()

            objConnection.Close()

    End Sub

  •  06-18-2006, 11:33 PM 20247 in reply to 20235

    Re: Saving editor contains to a SQL database

    Rune,
     
    Checks the string parameters in a SQL query for single quotes and replaces them with 2 single quotes where necessary.
    This is required for MS-SQL where you may need to have an apostrophe in a string.

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View as RSS news feed in XML