473,837 Members | 1,474 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 2483
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
5492
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 selection and displays actual articles for display. Adding the controls and getting everything...
6
3250
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 lineTable. As long as I am just displaying columns in the SQL database everything works well. I now want...
2
7817
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
3302
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 simple one, in theory anyway. The gist is to create a page where the user enters an IDNumber,...
2
1504
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): Dim drw1 As DataRow = dasUnitInfo.Tables("UnitInfo").NewRow() drw1("UnitNumber") = UnitNo...
2
5924
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
1722
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 dropdown, and all the values of that record then populate the fields on my form. Editing, and...
9
4463
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: '-2147483648' is not a valid value for 'index'.
2
3572
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
9682
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10566
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10623
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9401
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7806
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7001
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5669
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5848
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3124
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.