DataGridView and Autonumber

Hey guys,
I noticed that each time I insert a record in the DataGridView, I must fill out the ID column (primary key) as well. I have it set to autonumber in Access, and when I fill in data some other way it works, however in the DGView I have to fill it out manually or it will throw an Exception. Any Ideas?
Thanks!

[331 byte] By [Tryston02] at [2007-12-16]
# 1
Anybody?
Tryston02 at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 2

Hi,

Are you having problems retrieving the last auto generated number? try using the @@identity variable to retrive it.

SELECT @@IDENTITY AS ident

cheers,

Paul June A. Domag

PaulDomag at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 3
No, I'm using access. I'm not trying to retrieve anything. When I insert a row right into a DataGridView (it allows insertion, updating and deletion) I have to manually type the next ID (primary key) in instead of the autonumber doing it for me. I'm not submitting a form, I'm actually inserting the values straight into the datagrid.
Any ideas?
Thanks!
Tryston02 at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 4
What happens when you leave it blank?
dkocur2 at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 5

I have this problem as well.....bummer...did you get an answer?

Engineer1 at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 6

if i got your problem

i m giving you over view try to this

Dim snoColumn As New DataColumn

snoColumn.AutoIncrement = True

snoColumn.ColumnName = "sno"

snoColumn.DataType = System.Type.GetType("System.Int32")

snoColumn.AutoIncrementSeed =0

snoColumn.AutoIncrementStep = 1

and add this column to your dataset.table(0)

BlackBitsNeeraj at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 7

Hi

Check that the primary key Column AutoIncrement property is set to true.
Like

dgV.Columns["PK_ColumnName"].AutoIncrement = true;

Thanks

AkbarKhan at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 8

try the following code on form load event

dataset.tablename.fieldname.autoincrement=true.

Ren. at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...