Friday, March 24, 2006

Solution: AccessDataSource control generates error for autoincrement data type field while Inserting a record.

Following error you may faced:

"You tried to assign the Null value to a variable that is not a Variant data type. "


Solution:

When you use AccessDataSource control to insert a record in database. If one of field type is autoincrement then above error will shoot on the screen.

Normally you remove autoincrement data type fields from InsertCommand. This creates another problem. You don't face any error, but data is not saved in respective fields in database.

So here is a solution.

First, remove autoincrement field from InsertCommand.

Second, Important step, remove autoincrement field line from InsertParameters section of AccessDataSource control.

No comments:

Visitor Count: