473,408 Members | 1,908 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,408 software developers and data experts.

DataGrid and SQL GUID Column

Hi,
I have SQL DB table with a GUID Primary key. i used the C#
data form wizard to create a data form (though has a typed
dataset) with a Grid (the GUID column is not shown on the
grid). when the user adds a new row at the end of rows in
the grid (, types data in) and moves to another row the
error message appears: "primary key cant be null". what
should i do to make the system generate a new GUID for the
primary key column in the newly added row? (the default
value for the PK column is (newid()). but no default value
in the dataset properties) what event or default value i
should use?
thank you very much in advace.
Nov 15 '05 #1
1 5806
Leon,

In this case, you are going to have to hook into the Grid and find out
before the current row is changed (probably through the CellChanged event).
Once you have that, you will have to set the column in the data set to a new
guid value.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Leon" <r_*******@hotmail.com> wrote in message
news:05****************************@phx.gbl...
Hi,
I have SQL DB table with a GUID Primary key. i used the C#
data form wizard to create a data form (though has a typed
dataset) with a Grid (the GUID column is not shown on the
grid). when the user adds a new row at the end of rows in
the grid (, types data in) and moves to another row the
error message appears: "primary key cant be null". what
should i do to make the system generate a new GUID for the
primary key column in the newly added row? (the default
value for the PK column is (newid()). but no default value
in the dataset properties) what event or default value i
should use?
thank you very much in advace.

Nov 15 '05 #2

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

Similar topics

24
by: Ilija_G | last post by:
Hi, Is there any replace for "Select @@identity" that could return "just inserted" GUID as a primary key? Has anyone tested what's faster, working with Guid or Autonumber ?
2
by: Douglas Buchanan | last post by:
Some say there is no new row event for the VB.Net DataGrid. Hard to believe! Is that really true? I want to create a GUID in a hidden ID column when the user begins to enter data into a new row....
26
by: John Grandy | last post by:
Is it possible to generate a 20 byte integer from a GUID that is "unique enough" ( just like a GUID is not truly unique , but is "unique enough" ). We identify transactions with GUIDs , but a...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
4
by: John Smith | last post by:
How to add the tool tip to the datagrid column? I have a situation wherein the customer number is displayed in the datagrid column. I wanted to display the corresponding customer first and last...
4
by: Melson | last post by:
Hi I've created a GUID column of a table in ms sql server and bind the table to a datagrid. How can I automatically create new GUID when i add new row in the datagrid. Pls help. Thanks. ...
6
by: AlveenX | last post by:
Hi, I am trying to pick a Guid from a data row using the following code: foreach(DataRow row in MyDataTable.Rows) { (Guid)row }
14
by: Roy | last post by:
Is there an equivalent class function in C# to generate sequencial guid just like the NewSequentialID() function in SQL Server 2005?
8
by: Leon_Amirreza | last post by:
I have a column named "ID" and its type is "uniqueidentifier" in SQL Server 2005 Express. this column is the primary key and its default value is "newid()" in SQL Server. I have generated a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.