Solved

Using servlets to Insert some values in  Ms Access db?

Posted on 2002-03-29
4
343 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 50 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I remove an object from a 3 53
CSV file parsing thru Java 13 40
Java: The Public Class Main 4 45
How to fix  socket closed error 11 29
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

733 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