how to set up field in sqlDataAdapter before insert?

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
 
C

carion1

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().
 
S

Serdge Kooleman

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

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top