Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2005, 12:10 AM
2BaCook
Guest
 
Posts: n/a
Default Insert into error with java and MS Access

Hi, I have an Access database that I am creating a java front end to.
I am trying to insert a record into a table and get a problem whenever
I try to insert into my "Number" column.

Here is my table schema:
Column 1 Name: Number Type: VARCHAR
Column 2 Name: Street Type: VARCHAR
Column 3 Name: Phone Type: VARCHAR
Column 4 Name: Comments Type: LONGCHAR
Column 5 Name: Pets Type: VARCHAR
Column 6 Name: id Type: VARCHAR
Column 7 Name: Phone2 Type: VARCHAR
Column 8 Name: Email Directory Type: BIT


Here is my insert statement that creates the error:
queryString = "INSERT INTO Homes (id,Street,Number) VALUES ('5000a',
'Test Bend','5000');" ;
m_statement.executeUpdate(queryString);

This statement works, however:
INSERT INTO Homes (id,Street,Phone) VALUES ('5000b', 'Test
Bend','555-555-1234');

Here is the error:
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO
statement.
[Ljava.lang.StackTraceElement;@1a786c3
  #2  
Old November 13th, 2005, 12:10 AM
Salad
Guest
 
Posts: n/a
Default Re: Insert into error with java and MS Access

2BaCook wrote:
[color=blue]
> Hi, I have an Access database that I am creating a java front end to.
> I am trying to insert a record into a table and get a problem whenever
> I try to insert into my "Number" column.
>
> Here is my table schema:
> Column 1 Name: Number Type: VARCHAR
> Column 2 Name: Street Type: VARCHAR
> Column 3 Name: Phone Type: VARCHAR
> Column 4 Name: Comments Type: LONGCHAR
> Column 5 Name: Pets Type: VARCHAR
> Column 6 Name: id Type: VARCHAR
> Column 7 Name: Phone2 Type: VARCHAR
> Column 8 Name: Email Directory Type: BIT
>
>
> Here is my insert statement that creates the error:
> queryString = "INSERT INTO Homes (id,Street,Number) VALUES ('5000a',
> 'Test Bend','5000');" ;
> m_statement.executeUpdate(queryString);
>
> This statement works, however:
> INSERT INTO Homes (id,Street,Phone) VALUES ('5000b', 'Test
> Bend','555-555-1234');
>
> Here is the error:
> [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO
> statement.
> [Ljava.lang.StackTraceElement;@1a786c3[/color]

Just guessing.

Phone numbers usually aren't stored as numbers in a table...usually they
are strings. So I can understand why the phone number works if that is
the case. I'm not sure why you want to stuff a string into a number
field unless the field Number, in the table, is a string. What happens
if you remove the single quotes around the number 5000?



 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles