|
 |
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
 |
|
|
 |

March 30th, 2005, 12:02 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Help adding a row to a data table.
To make the explination short, what I have is a listbox bound to a dataset. I want to add a custom row to the dataset so that it is on top of the listbox. This is my code, however I keep getting an error: "Object Reference not set to an instance of an object"
Dim dr As dsSites.SitesRow '<-- My dataset row
dr.SiteID = 0 '<--The error occurs here
dr.Site = "DUMMY"
dr.Address1 = "DUMMY" '
dr.Address2 = "DUMMY" '
dr.City = "DUMMY"
dr.State = "DUMMY"
dr.Zip = "99999" ''
dr.Phone = "9999999999"
DsSites1.Tables(0).Rows.InsertAt(dr, 0) '<--Should put the row on top of the dataset.
Any help would be appreciated.
Jim
|

March 30th, 2005, 12:22 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Ok everyone, I fixed that problem but now have a new one.
The row gets inserted but always shows up on the bottom of my listbox, even when I use InsertAt(dr, 0).
Any Help?
Thanks
|

March 30th, 2005, 02:06 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
|
|
I am currently working on an application with almost the same code except that I am not binding my data and mine is inserting it in the correct spot.
Are you sure that it isn't inserting correctly in your dataset table and then just placing it in the wrong place in the listbox? I am not sure if since it is bound it will just automatically add that value to the bottom of the listbox even though you insert it at a different spot.
After inserting it in the dataset, can you loop through the dataset and output it to the debugger window to see the order?
J
|

March 30th, 2005, 02:12 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Thanks for the reply. Acutally what I have is a DataView tied to the dataset table. I use it for filtering. What I did was, place a sort on the dataview, after the dataset was filled. This cured my problem.
I am not sure, but I think it has something to do with binding order. It as if it inserts the row after binding, but then you have to reorder. I am not sure.
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |