generate Primary Key automaticaly

0 views
Skip to first unread message

trouffiondesiles

unread,
Nov 9, 2009, 7:59:59 AM11/9/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
HI,

I have a problem when i add a row to my slq Server Database.

There is how i add this row :


DB.getSqlDataSet(RequeteAll, DataSetAll,
TableName)
Dim Primary_Key_Columns(0) As DataColumn
Primary_Key_Columns(0) = DataSetAll.Tables
(TableName).Columns("PKPlanning")
DataSetAll.Tables(TableName).PrimaryKey =
Primary_Key_Columns

ObjDataRow = DataSetAll.Tables(TableName).NewRow
'PrimaryKey = DB.GetNewPrimaryKey(DataSetAll,
"PKPlanning", TableName)
'ObjDataRow("PKPlanning") = 50
ObjDataRow("PKUser") = Item.PKUser
ObjDataRow("PKMonth") = Item.PKMonth
ObjDataRow("PlanningDay") = Item.PlanningDay
ObjDataRow("PKHoraire") = Item.PKHoraire

DataSetAll.Tables(TableName).Rows.Add(ObjDataRow)


On the row.add i have an error that PKPlanning can't obtain a NULL
result.

The Colums PKPLanning is configured into PrimaryKey with
autoincrement.

Have somebody an answer for my problem??

(Sorry for my english i'm french...)


Bye, Nicolas.

Raghupathi Kamuni

unread,
Nov 10, 2009, 1:48:57 AM11/10/09
to dotnetde...@googlegroups.com
Set AutoIncrement, AutoIncrementSeed, AutoIncrementStep properties for the primary key column
 
With Primary_Key_Columns
  .DataType = System.Type.GetType("System.Int32")
  .ColumnName = "PKPlanning"
  .AutoIncrement = True
  .AutoIncrementSeed = -1
  .AutoIncrementStep = -1
End With

Reply all
Reply to author
Forward
0 new messages