Whelkaholism
Whelkaholism

Reputation: 1495

TableAdapter wizard not generating INSERT method - UPDATE and DELETE fine

I have inherited a project with an Access backend, using TableAdapters which I've not used before.

Most of the tables in the schema work fine, but a single one is not generating the INSERT statement and insert method.

I have checked everything mentioned here: http://msdn.microsoft.com/en-us/library/ms233812(vs.80).aspx

The adapter is using a simple query on a single table, the checkboxes for generating statements and methods are ticked and the table has a primary key. UPDATE and DELETE work fine.

Is there anything else that could be affecting this?

Upvotes: 2

Views: 3731

Answers (5)

effecasa
effecasa

Reputation: 1

The INSERT command is not generated because not all the NOT NULL columns are included in your fields selection. You must include them or set a default value in the table definition on the database

Upvotes: 0

Missy
Missy

Reputation: 1368

I had the same problem. I went to my first tableadapter query and changed it from "Select fid1, fid2, fid3 from filename" to "Select * from tablename" and checked that I wanted the inserts, updates, etc generated. It generated all new commands. Worked great.

Upvotes: 0

Gerson Izaguirre
Gerson Izaguirre

Reputation: 19

I had the same problem, but I noticed something the table had no primary key, solve it by adding the primary key, now it works fine, have you tried that?

Upvotes: 2

Phil Jeffrey
Phil Jeffrey

Reputation: 11

I had the same issue, and discovered that the INSERT command was not created if I had omitted fields from the dataset that were NOT NULL in the database. Once I included the NOT NULL fields in the dataset, the INSERT command was created.

Upvotes: 1

bendataclear
bendataclear

Reputation: 3848

Go into the xsd file and look at the properties of the TableAdaptor, you should have an entry for InsertCommand. If this is missing you can add it manually.

This assumes you are using an xsd file obviously.

Edit:

Have you tried adding a new TableAdaptor using the wizard attached to the same table to see if it generates without the insert command?

Upvotes: 2

Related Questions