none
How to solve System.Data.OleDbException (0x80040E14): Syntax error (missing operator) in query expression..

    Question

  • The codes are..

     Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
            conn.ConnectionString = connstring

            If conn.State = ConnectionState.Closed Then
                conn.Open()

            Else
                MsgBox("Close")
            End If

            If (String.IsNullOrWhiteSpace(TextBox1.Text)) Then
                MessageBox.Show("PLEASE FILL IN ALL THE BOXES")
            ElseIf (String.IsNullOrWhiteSpace(TextBox2.Text)) Then
                MessageBox.Show("PLEASE FILL IN ALL THE BOXES")

            ElseIf (String.IsNullOrWhiteSpace(RichTextBox1.Text)) Then
                MessageBox.Show("PLEASE FILL IN ALL THE BOXES")
            End If

            Try

                Dim SqlQuery As String = "INSERT INTO Research (Title,Abstract,Proponents,Ryear) VALUES ('" & TextBox1.Text & "', '" & RichTextBox1.Text & "', '" & TextBox2.Text & "', '" & DateTimePicker1.Text & "')"
                Dim SqlCommand As New OleDbCommand


                With SqlCommand
                    .CommandText = SqlQuery
                    .Connection = conn
                    .ExecuteNonQuery()


                End With
                MsgBox("One record Succesfully Added")
            Catch ex As Exception


                MsgBox(ex.ToString)

            End Try
            Me.Close()
            main.Show()



        End Sub

    *********************************

    The situation is, I cannot add data if it is copied from the text from the ms word and paste it to the RichTextbox in my project..I can only add if I type Manually the data the richtextbox..If I copy paste it..this error comes out.

    Please help me to solve this problem..i attached the image of the error

    Tuesday, May 13, 2014 5:35 AM

Answers

All replies