473,395 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to set up field in sqlDataAdapter before insert?

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

Nov 17 '05 #1
2 3688
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().

--

Derek Davis
dd******@gmail.com

"Serdge Kooleman" <Su***@web.de> wrote in message
news:O%****************@TK2MSFTNGP15.phx.gbl...
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

Nov 17 '05 #2
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

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?"

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Christoph | last post by:
I'm delving into using ADO.NET for the first time. In fact, I've never done any database work using C# at all so all of this is new to me. Please bear that in mind if I am asking stupid questions....
3
by: LP | last post by:
Hello, In the past I used SqlCommandBuilder and SqlDataAdapter .Update method to apply changes in a DataTable back to its table source in SQL Server. It worked fine when DataSet had only 1...
1
by: archana | last post by:
hi all I have some doubts related to database handling in .net. I am using sqldataadapter to update and insert rows into database. What i want to know is at a time of inserting rows using...
1
by: archana | last post by:
Hi all I ma having problem in sqldataadapter. In my sql database i have one table containing column name as 'Name and address'. Here 'and' is reserved word which i am using in column name. In...
2
by: Aaron | last post by:
Hello, The SqlDataAdapter has 4 properties of type SqlCommand, SelectCommand, UpdateCommand, DeleteCommand, and InsertCommand. Setting the SelectCommand allows the SqlDataAdapter to retrieve...
0
by: dphill | last post by:
Hello all I am a beginner .Net programmer so please forgive my ignorance. In brief, I am trying to read from xml file stored in a SQL database table’s field. This is what I used to create...
1
by: niccolem | last post by:
HI: Can someone tell me HOW to insert a automatic number after my user inserts new data from text boxes into the dataset. I keep getting this error: Cannot insert the value NULL into column 'id',...
1
by: RN1 | last post by:
When using the SqlCommand object, records can be inserted/updated/ deleted in the underlying data source (i.e. the SQL Server database table) directly by using code like this: ...
2
by: DaveL | last post by:
Hello all, Im inserting 100 rows into the database i need the Identity column back. Im not sure how to accomplish this... Using SqlDataAdapter Ive Tried samples that i found..but can't get...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.