473,569 Members | 2,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding a blank row to a datatable

Roy
Hi all,
I do have a datatable that looks like:
id Number Description
1 1 Desc1
2 1 Desc2
3 2 Desc3
I need this datatable looks like (with 4 rows which the third one is blank):
id Number Description
1 1 Desc1
2 1 Desc2

3 2 Desc3
Any suggestions would be appreciated.
Roy

Nov 21 '05 #1
2 2458
Hi Roy,

Thats doesn;t really make sense. One of the primary tenants of a relational
databases is the the order of the rows is unimportant. Secondly why would
you want to store NOTHING?

If this is for some kind of output/report then you'd be better of telling
us what you're doing so we can advise with a another code based strategy.
If you want to stick with your blank row then you'll be relying on
inserting NULLs /and or white space. This will not be possible however if
your Id column is autonumbered/incrementing.

This will still not get you around any sorting however because this null
row will be placed at either the top or the bottom when sorted.

Richard

"Roy" <Ro*@discussion s.microsoft.com > wrote in message
news:A3******** *************** ***********@mic rosoft.com...
Hi all,
I do have a datatable that looks like:
id Number Description
1 1 Desc1
2 1 Desc2
3 2 Desc3
I need this datatable looks like (with 4 rows which the third one is blank): id Number Description
1 1 Desc1
2 1 Desc2

3 2 Desc3
Any suggestions would be appreciated.
Roy

Nov 21 '05 #2
Roy
Hi Richard,
As you guessed this is for reporting purpose. I was not able to run a sql
statement that returns a datatable with the blank rows. The datatable has
already been sorted and I need to loop through the rows and check for the
Number column. If there is a change then I need to insert a blank row that
each column has a value of NULL. To do this I've created another datatable
and when I'm looping through the original datatable if there is not a change
in this column I insert the oringinal row into the new datatable otherwise I
insert a new record with null values. This is working, but it doesn't look
very impresive and I wonder if there is a better way to do this.
Thanks again
Roy

"Richard Myers" wrote:
Hi Roy,

Thats doesn;t really make sense. One of the primary tenants of a relational
databases is the the order of the rows is unimportant. Secondly why would
you want to store NOTHING?

If this is for some kind of output/report then you'd be better of telling
us what you're doing so we can advise with a another code based strategy.
If you want to stick with your blank row then you'll be relying on
inserting NULLs /and or white space. This will not be possible however if
your Id column is autonumbered/incrementing.

This will still not get you around any sorting however because this null
row will be placed at either the top or the bottom when sorted.

Richard

"Roy" <Ro*@discussion s.microsoft.com > wrote in message
news:A3******** *************** ***********@mic rosoft.com...
Hi all,
I do have a datatable that looks like:
id Number Description
1 1 Desc1
2 1 Desc2
3 2 Desc3
I need this datatable looks like (with 4 rows which the third one is

blank):
id Number Description
1 1 Desc1
2 1 Desc2

3 2 Desc3
Any suggestions would be appreciated.
Roy


Nov 21 '05 #3

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

Similar topics

4
5465
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last...
6
3227
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order entry application. The code below gets line items from a SQL Server database and returns them to a datagrid by way of a DataTable called...
2
7801
by: Chris | last post by:
I was wondering if there was any way to add a blank list item control to the beginning of the System.Web.UI.WebControls.DropDownList's datasource after the control's datasource has been specified. Here's my code right now: Dim oEmptyOption as New ListItem() 'Assign datasource to delivery date type combobox
1
3267
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple days of struggling, I figure asking you all (the experts) will keep me from going down some dark and dangerous road. The project I have is a fairly...
2
1490
by: Niels Jensen | last post by:
I have the following code in a Sub which is called by a do loop statement for each line starting with unit info in an e-mail based game that I play. I'm exctracting the keywords from the text and then trying to add them to a dataset that draw's it's columnnames from an empty access database table (the primary key of the database is UnitNo): ...
2
5903
by: Sam | last post by:
hi, I have a combox in a datagrid linked to a dataset. I fill the dataset using my own customised class and it works fine. da.AddTable("select FieldTypeID, FieldType from FieldTypes", DatabaseAccess.SQLType.Text) m_dsFields = da.GetDataset Dim r As New DataRow m_dsFields.Tables(1).Rows.Add(r)
1
1713
by: JohnR | last post by:
I'm using oledb to an Access datatable. I load the table into a dataset. I create databindings to link the fields on my form to the corresponding fields in the datatable. The tables DefaultView.Sort is set to the field that is bound to a dropdown (where I can pick what record to view, and the dropdown list is sorted). I click a rec in the...
9
4446
by: Kay | last post by:
Hi all, Could you tell me the best way to add a blank item(as first item) in a data binded combo box? Because I think I didn't do it right and it generate an error if the second item(after the top blank item) is selected by using Combo.SelectedValue : "Specified argument was out of the range of valid values. Parameter name:...
2
3549
by: Flack | last post by:
Hey guys, I have a DataGrid and DataTable field in my class : private ImageDataGrid dataGrid1; //ImageDataGrid extends dataGrid and just overides OnMouseDown private DataTable dt = new DataTable("MyTable"); In the classes constructor, after InitializeComponent() I call the following
0
7700
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7974
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.