If you try to use ASP.NET AccessDataSource then you may face a problem while inserting rows to database through the dataSource. It happens when you have an auto increment identity column. When you drag & drop an AccessDataSource Visual Studio.NET generates the SELECT, INSERT, DELETE, UPDATE Command for you as your chosen option. But you will get exception message when you try to save a new row. The cause is the generated insert query is wrong. Actually VS.NET don't consider the identity column and try to insert value in the column.
The work around is just remove the ID column from the insert command and remove a parameter('?') from the query parameter list. Also remove the ID column info from the insert command parameter collection.
Then you will find its working fine.
No comments:
Post a Comment