Saving Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsgurdeep
    New Member
    • Apr 2007
    • 94

    #1

    Saving Error

    When I insert rtf data from rich text box in sql table containing 3 char(255) type columns + char(6000) columns it returns access violation error.

    what it mean
    &
    waht is the solution

    Please Help Me soon
  • truezplaya
    New Member
    • Jul 2007
    • 115

    #2
    i think you need to do more reasearch in to this before posting comments on here otherwise you will have the admin telling you that they don't give answers you work towards your answers

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by gsgurdeep
      When I insert rtf data from rich text box in sql table containing 3 char(255) type columns + char(6000) columns it returns access violation error.

      what it mean
      &
      waht is the solution

      Please Help Me soon

      What is causing the error?
      The code accessing the rich text box?
      Or the code saving the information to the database?

      Please post your error message and explain your problem in more detail so that we can help you better. Include things like: What you've tried so far, What you think is causing the problem, and any error messages are you getting

      -Frinny

      Comment

      • gsgurdeep
        New Member
        • Apr 2007
        • 94

        #4
        I used to post my problems after lot of search on Google & MSN.
        There is no specific error message, only says Saving data in table fails.

        Comment

        • MrMancunian
          Recognized Expert Contributor
          • Jul 2008
          • 569

          #5
          Can you insert your code in a Try...Catch-block and see what 'ex' is returning? Otherwise, it's impossible for us to come up with an answer...

          Steven

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            Originally posted by gsgurdeep
            I used to post my problems after lot of search on Google & MSN.
            There is no specific error message, only says Saving data in table fails.
            I would check to make sure that your SQL statement for saving the data is correct.
            Use something like Query Analyzer to test your SQL.

            Comment

            • gsgurdeep
              New Member
              • Apr 2007
              • 94

              #7
              If I insert plaint text data inserted successfully. but when i used any bulleted rich text it throw error says. "Error Insert"
              Try Catch block is replied same.

              but when
              I used Query Analyzer for inserting data.....
              this reply with an error.......... says
              Access Violation...... .......

              Please Help Me ......

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Any chance we'll get to see the code that's inserting the rich text?

                Comment

                • gsgurdeep
                  New Member
                  • Apr 2007
                  • 94

                  #9
                  Here is my code
                  Code:
                  DIM conString As String = "provider=SqlOleDb; Data Source=SERVER;Initial Catalog=DATA_BASE;Persist Security Info=True;User ID=SA"
                  
                  Dim  m1, m2, m3, m4, m5 As String
                  
                  m1=0
                  m2 =text_name.Text.Trim 'ITEM MODEL
                  m3 = text_part.Text.Trim 'ITEM PART NO.
                  m4 = rich_text.Rtf.Trim 'ITEM DESCRIPTION OR SPECIFICATION
                  m5 = text_model.Text.Trim  'ITEM MODEL NO.
                  
                  Try
                              Dim Db As OleDb.OleDbConnection
                              Dim Cmd As OleDb.OleDbCommand
                              Dim Rs As OleDb.OleDbDataReader
                              Db = New OleDb.OleDbConnection(conString)
                              Db.Open()
                              Cmd = New OleDb.OleDbCommand
                              Cmd.CommandText = "Insert Into items Values ('" & m1 & "', '" & m2 & "', '" & m3 & "', '" & m4 & "', '" & m5 & "')"
                              Cmd.Connection = Db
                              Rs = Cmd.ExecuteReader
                              Rs.Close()
                              Db.Close()
                  Catch ex As Exception
                              MsgBox("insert+++++++++++++" & ex.Message)
                  End Try
                  it works fine if i use

                  Code:
                  m4 = rich_text.text.Trim
                  in place of
                  Code:
                  m4 = rich_text.Rtf.Trim
                  please help me

                  Comment

                  • r035198x
                    MVP
                    • Sep 2006
                    • 13225

                    #10
                    Shouldn't you be using ExecuteNonQuery instead of ExecuteReader which you only use for select statements?
                    Make that change, try it and post the full error message that you get exactly as it is.

                    P.S You should also be using parameters for this type of thing.

                    Comment

                    • gsgurdeep
                      New Member
                      • Apr 2007
                      • 94

                      #11
                      I Have used ExecuteNonQuery instead of ExecuteReader, But Result is same.

                      Again Modified code run well with
                      Code:
                      m4=rich_text.text.trim
                      but says error when
                      Code:
                       m4=rich_text.rtf

                      My Try Catch Block says following Error
                      " Syntex Error or Access Violation. "

                      Comment

                      • r035198x
                        MVP
                        • Sep 2006
                        • 13225

                        #12
                        Now print out the command text before executing the query to see if your command is valid. Post the text that's printed as well.
                        P.S Which version of SQL server are you using (if you are using SQL server that is)?

                        Comment

                        • raids51
                          New Member
                          • Nov 2007
                          • 59

                          #13
                          what might be happening is that some character in the string(because with all those weird characters that the rtf format puts in there ) may be messin with sql and tellin it to do some command, kinda like how sql injection works(putting quotes in the beginning of the string will allow you to run a sql command on it EX the query 'and 1=1 in a login name would tell sql server the command if password = '' and 1=1 then login.... if im not bein clear then you can google this). so this would throw a syntax error. im just puttin some ideas out there.

                          Comment

                          Working...