Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 30th, 2005, 12:02 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default 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
Reply With Quote
  #2 (permalink)  
Old March 30th, 2005, 12:22 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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

Reply With Quote
  #3 (permalink)  
Old March 30th, 2005, 02:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

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
Reply With Quote
  #4 (permalink)  
Old March 30th, 2005, 02:12 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT adding new data in new row mingfatty Access 1 February 8th, 2007 08:24 AM
Adding new row ShaileshShinde Access VBA 23 July 5th, 2006 08:26 AM
UPDATING 1 row with another row in same table rit01 SQL Server 2000 3 February 19th, 2006 08:55 AM
Manage data row by row in datagrid Dragonist Classic ASP Databases 5 July 29th, 2004 04:17 AM



All times are GMT -4. The time now is 03:16 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.