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? |