Solved

Using servlets to Insert some values in  Ms Access db?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

760 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

17 Experts available now in Live!

Get 1:1 Help Now