Protected
Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim Title, Abstract, Comments As String
Dim Display As Integer
Dim NewsDate As Date
Title =
Me.rtxtTitle.Text
Abstract =
Me.redAbstract.Text
Dim strAbstract = Abstract.Substring(0, Abstract.Length - 1)
Comments =
Me.redComments.Text
Dim strComments = Comments.Substring(0, Comments.Length - 1)
NewsDate =
Me.rdtpNews.DbSelectedDate
If Me.chkDisplayYN.Checked = True Then
Display = 1
Else
Display = 0
End If
'Populate the datatable
Dim sConnString As String = ConfigurationManager.ConnectionStrings("PU89").ConnectionString
Dim objConnection As New SqlClient.SqlConnection(sConnString)
Dim strSQL As String = "INSERT INTO tblNews (Title,Display,BDate,Abstract,Comments)" & _
" VALUES ('" & Title & "', '" & Display & "', '" & NewsDate & "', '" & strAbstract & "', '" & strComments & "');"
Dim dbComm As New SqlClient.SqlCommand(strSQL, objConnection)
Dim iID As Integer
Try
objConnection.Open()
iID = dbComm.ExecuteScalar()
Catch ex As Exception
Response.Write(ex.Message)
Response.End()
Finally
If objConnection.State = ConnectionState.Open Then
objConnection.Close()
End If
End Try
End Sub
This method works for short blocks of text with no special characters. When I try to enter the complete text (copied from a webpage and pasted into the RadEditor) I get syntax errors:
"Incorrect syntax near 's'. Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon."
Thanks,
Shelley