Solved

Using servlets to Insert some values in  Ms Access db?

Posted on 2002-03-29
4
318 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 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now