Saving editor contains to a SQL database

  •  06-17-2006, 2:45 PM

    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

View Complete Thread