Re: don't know what exactly is wrong

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Frank Hickman (fhickman_nosp_at_m_noblesoft.com)
Date: 03/05/04


Date: Thu, 4 Mar 2004 21:08:07 -0500

All of your \ characters must be escaped like so \\. So instead of \rtf you
must have \\rtf. \ is the escape character for string literals.

HTH

-- 
============
Frank Hickman
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.
"Chris Ellis" <praiseGod777@RemoveThis_hotmail.com> wrote in message
news:eo3jlVkAEHA.3184@TK2MSFTNGP09.phx.gbl...
> Hi,
>
>     I'm attempting to store Rich Text Format data in a memo field in an
> Access2000 database.  I am updating from an Access97 database in which I
> used the same memo field to store plain text.  I am programmatically
> grabbing the text, applying RTF codes to it, and then attempting to store
> that data in the same memo field in the new Access2000 database.  I can't
> even get past the first record.  I am obviously forming a bad query, but I
> don't know exactly what's wrong with it (or what to do to fix it).  Here
is
> the exact query that is failing:
>
> INSERT INTO Notes ([Title],[Note],[Date]) VALUES ('Bara vs.
>
Asah','{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\
> fcharset0 Arial Black;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs24 In the
> beginning, God  CREATED (Bara)... bara speaks of creation, but in Genesis
> 1:26, God spoke of  MAKING  man in His image... make = Asah, which puts
more
> emphasis on fashioning that which is created... so, God created the
> universe, but He is fashioning us into His image.  Asah also deals with
> refinement.\\par\r\n}\r\n\0',NULL);
>
> sorry for that giant heap of garbage, but I do string concatenation to get
> it how I want it.  If it were all broken apart correctly, to be more
> readable, it would look like this:
>
> INSERT INTO
> Notes
> (
>     [Title],
>     [Note],
>     [Date]
> )
> VALUES
> (
>     'Bara vs. Asah',
>
>
'{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fchars
> et0 Arial Black;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs24 In the beginning,
God
> CREATED (Bara)... bara speaks of creation, but in Genesis 1:26, God spoke
of
> MAKING  man in His image... make = Asah, which puts more emphasis on
> fashioning that which is created... so, God created the universe, but He
is
> fashioning us into His image.  Asah also deals with
> refinement.\\par\r\n}\r\n\0',
>     NULL
> );
>
> The Title field is a Text field with a field size of 30
> The Note field (which I'm sure is where the problem must be) is a Memo
field
> And the Date field is a Date/Time field set to General Date and is not
> required.
>
> I am programming in C# and I'm using the OleDb objects (which is why I
> posted here).  I originally posted this message to
> microsoft.public.access.queries.  Someone replied and told me that the
query
> worked just fine.  I opened access and pasted my query text in as a query
> and it ran perfectly, inserting the proper values into my table.  So, I
now
> assume that this must be a problem with my usage of OleDb.  I am
developing
> in Visual Studio 2003.  I am constructing an OleDbCommand object with the
> above query, and calling the ExecuteNonQuery method and I get the
following
> exception:
>
> System.Data.OleDb.OleDbException: Syntax error in string in query
expression
> ''{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0
> Arial;}}
> \viewkind4\uc1\pard\fs24 In the beginning, God  CREATED (Bara)... bara
> speaks of creation, but in Genesis 1:26, God spoke of  MAKING  man in His
> image... make = Asah, which p'.
>    at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32
> hr)
>    at
>
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
> dbParams, Object& executeResult)
>    at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
> executeResult)
>    at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
> behavior, Object& executeResult)
>    at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
> behavior, String method)
>    at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
>    at HelperClasses.JetConnection.ExecuteNonQuery(String sql) in
> c:\code\net\c#\helperclasses\jetconnection.cs:line 346
>    at HelperClasses.JetConnection.InsertRecord(String Table, String[]
> Fields, Object[] Values) in
> c:\code\net\c#\helperclasses\jetconnection.cs:line 226
>
> I have no idea why.  As I said, the query, copied exactly into access,
runs
> just fine, so I'm assuming that the problem is either in OleDb, or it's in
> my use thereof.  If this is not the correct newsgroup for this question,
> please point me in the right direction.
>
> Thanks in advance for any help,
> Chris
>
>


Relevant Pages

  • dont know what exactly is wrong
    ... that data in the same memo field in the new Access2000 database. ... I am obviously forming a bad query, ... God spoke of MAKING man in His image... ... make = Asah, which puts more ...
    (microsoft.public.data.oledb)
  • RE: Linked Table Query Problems (SQL Server ODBC)
    ... Try and change the query to a pss through query, to see what the result you ... >> in using Like if the filter is for the whole string and not for a part of a ... >> In God We Trust - Everything Else We Test ... >>> FROM Absences ...
    (microsoft.public.access.queries)
  • Re: Problems with Delete Command
    ... The SQL could get fairly messy if you need to construct it in code, ... ContactID, and WebComID, and create your on-the-fly SQL on that saved query, ... to find the list of ContactIDs from the junction table, ... This is a style/readability thing: if you are going to use string ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Need help with Code Please!!!
    ... the actual string that gets built at the end of the SQ1 build process. ... The message says Syntax error in query expression ... Dim rs As Recordset 'object ref to qryCompany\USFNumber ...
    (microsoft.public.access.formscoding)
  • Re: Need help with Code Please!!!
    ... putting the query SQL itself in here maybe it will help you understand what I ... the actual string that gets built at the end of the SQ1 build process. ... Dim rs As Recordset 'object ref to qryCompany\USFNumber ... Dim qd As QueryDef 'object ref to query item ...
    (microsoft.public.access.formscoding)