how to set up field in sqlDataAdapter before insert?

  • Thread starter Thread starter Serdge Kooleman
  • Start date Start date
S

Serdge Kooleman

i have a query: select id, name from Dictionary
field "id" is uniqueidentifier (primary key id is not null, and not identity
!)
i show only "name" in the dataGrid

how to set up new id when i insert a new record? from the c#? from the sql?

INSERT INTO Dictionary (id, name) VALUES (@id, @name );

Always i'm getting message: "Column "id" doesn't allow nulls. Do you want to
correct
the value?"

thank you
 
Look at newid() if you want to assign id in the SQL or you can set the
default value of id to newid(). In c# you can use System.Guid.NewGuid().
 
In c# you can use System.Guid.NewGuid().

could you give a code example please?
what event should i use? do we have "before insert" in .Net?
if yes, then where, what component?


serge

 
Back
Top