?
Solved

Using servlets to Insert some values in  Ms Access db?

Posted on 2002-03-29
4
Medium Priority
?
366 Views
Last Modified: 2013-11-24
Let say you have three fields in a database and one of the fields hold the primary key. Now you want to add two values of the other fields using servlets such that the primary key is automatically added automatically(i.e auto- number) with each an every record added for the two fields.Coz I am encounting errors like the destination fields are not equal when i send the two fields excluding the primary key.

When I assign a null value to a primary key this is what I get

Cannot connect java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] You tried to assign the Null value to a variable that is not a Variant data type.
0
Comment
Question by:wbmorapedi
  • 2
4 Comments
 
LVL 4

Expert Comment

by:pellep
ID: 6905767
What database are you using. Most databases allow you to specify a field as 'identity' with auto-increment. This means that the value of the field gets set by the DBMS when you insert new rows.
0
 

Expert Comment

by:cxj97c
ID: 6905944
and,
when you write to the db leave the primary key field null.

i.e.

example: insert into something one, two, three values "null", "something", "something"

Where one is your pk.

0
 
LVL 3

Accepted Solution

by:
msterjev earned 100 total points
ID: 6906650
Yust specify fields into the statemet, for example if you have three fields fOne,fTwo,fThree and fOne is primary key (I suppose it is autoincremental in Access), then you don't specify this field into statement nor send null value for this field. So the statemet is:


ISERT INTO MyTable fTwo,fThree VALUES(value2,value3);

0
 
LVL 3

Expert Comment

by:msterjev
ID: 6909952
The points, thank you!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month17 days, 3 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question