Insert statement and other characters 
Author Message
 Insert statement and other characters

I need to insert a string into a memo field in an access
database that has reserved characters in it.  I was
wondering if this was possible through a sql statement.  
Consider the following example.

Text1.text = "Length = 5'6"
strSql = "Insert into Table (XLen) Values ('" & text1.text
& "')"
mscnn.execute strsql

With that statement, I will get errors.  Does anyone know
what I can do to avoid this?

The characters I have trouble with are ', ", and #.

Thanks for any help you can give.

Robert



Sun, 18 Apr 2004 03:29:24 GMT
 Insert statement and other characters

Hi Robert,

If you have ' inside your text then you need to double
them. In that case SQL will recognize apostrophie as a
symbol, not as a beginning or end of string value. To do
that use next code

Text1.text = "Length = 5'6"
strSql = "Insert into Table (XLen) Values ('" & Replace
(text1.text, "'", "''") & "')"
mscnn.execute strsql

Val

Quote:
>-----Original Message-----
>I need to insert a string into a memo field in an access
>database that has reserved characters in it.  I was
>wondering if this was possible through a sql statement.  
>Consider the following example.

>Text1.text = "Length = 5'6"
>strSql = "Insert into Table (XLen) Values ('" &
text1.text
>& "')"
>mscnn.execute strsql

>With that statement, I will get errors.  Does anyone know
>what I can do to avoid this?

>The characters I have trouble with are ', ", and #.

>Thanks for any help you can give.

>Robert
>.



Sun, 18 Apr 2004 03:56:24 GMT
 Insert statement and other characters
Thanks Val.  I have seen that you have helped a lot of
people on the board.  We all appreciate it very much.

Robert

Quote:
>-----Original Message-----
>Hi Robert,

>If you have ' inside your text then you need to double
>them. In that case SQL will recognize apostrophie as a
>symbol, not as a beginning or end of string value. To do
>that use next code

>Text1.text = "Length = 5'6"
>strSql = "Insert into Table (XLen) Values ('" & Replace
>(text1.text, "'", "''") & "')"
>mscnn.execute strsql

>Val

>>-----Original Message-----
>>I need to insert a string into a memo field in an access
>>database that has reserved characters in it.  I was
>>wondering if this was possible through a sql statement.  
>>Consider the following example.

>>Text1.text = "Length = 5'6"
>>strSql = "Insert into Table (XLen) Values ('" &
>text1.text
>>& "')"
>>mscnn.execute strsql

>>With that statement, I will get errors.  Does anyone
know
>>what I can do to avoid this?

>>The characters I have trouble with are ', ", and #.

>>Thanks for any help you can give.

>>Robert
>>.

>.



Sun, 18 Apr 2004 04:04:07 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. illegal character error with INSERT statement and &BIND

2. Insert characters to existing character field

3. Ultimate Question: Oracle, MSSQL, Others vs MYSQL LIMIT Statement

4. SQL statement works sometimes but not others

5. Ultimate Question: Oracle, MSSQL, Others vs MYSQL LIMIT Statement

6. Ultimate Question: Oracle, MSSQL, Others vs MYSQL LIMIT Statement

7. Ultimate Question: Oracle, MSSQL, Others vs MYSQL LIMIT Statement

8. Inserting records "between" others

9. insert into one table with selects from 4 others

10. insert statement using values from a select statement

11. Conditional Statements in the INSERT-SELECT statement!


 
Powered by phpBB® Forum Software