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

Parent/child table problems

Using VS 2003, VB.NET, SQL MSDE..

I am stumped. I have a datagrid with a parent/child relationship between
two tables. If I add 200 rows from code in the same win form to the child
table with only the parent table displayed, it works fine, and then you can
display the child table and all data is as expectect.

If I display the child table, and do the exact same thing, try to add 200
rows, only a a few (max 10) are added and displayed, and then I get error
messages like below at the "form.showdialog" that displayed the win form to
begin with:

This is the 1st error after about 10 rows added
System.NullReferenceException - object refereced not set to an instance of
an object

If you hit continue, you get this error next

System.runtime.interopservices.SEHException - external component has thrown
an exception

These are using DataAdapters created in component designer, with max
connections set to 800 in my SQL string to avoid know bug of connections not
being released.

What is up?

Bob Day
Nov 20 '05 #1
3 1470
Hello Bob,

Thanks for your post. I reviewed your description carefully, and think more
information is needed before moving forward:

1. Please check the call stack and tell me when it throws the exception.
2. Is it possible for you to post a simple project which is able to
reproduce the problem? I will be glad to check it on my side.

I look forward to hearing from you.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #2
Can you send me or point me to a URL for an example of an partent/child
table that 200 rows are simultaneously added via 2 thread to the child table
with the child table displayed that works?

I have spend days on this, and cannot get it to work. At this point, I am
considering dumping it and going a different route.

I cannot see how to send you a simply example, since it is all coming from
SQL.

Thanks
Bob Day

"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:Fl**************@cpmsftngxa07.phx.gbl...
Hello Bob,

Thanks for your post. I reviewed your description carefully, and think more information is needed before moving forward:

1. Please check the call stack and tell me when it throws the exception.
2. Is it possible for you to post a simple project which is able to
reproduce the problem? I will be glad to check it on my side.

I look forward to hearing from you.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #3
Hello Bob,

Thanks for your response. Now I understand that your application is
multi-threaded that you add rows to child table from within another thread.
Please correct me if there is any misunderstanding. I'd like to share the
following information with you:

I believe that the exception NullReferenceException may be caused by
synchronization issue in your application. In a multi-threaded application,
you have to do some synchronization on data to prevent two threads access
one data at the same time. To work around the problem, you should add rows
to child table in the main thread. Please refer to the following code
snippet:

//----------------code snippet-----------------------
private System.Data.DataRow dr;

public DG()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

dataGrid.DataSource = myDataset;
dr = null;

ThreadStart threadStart = new ThreadStart(listenThread);
Thread thread = new Thread(threadStart);
thread.IsBackground = true;
thread.Start();
}

private void listenThread() //Generate new data
{
while ( running )
{
lock(this)
{
if(this.dr == null)
{
dr = myDataset.MyTable.NewMyTableRow();
dr[0] = DateTime.Now;
dr[1] = random.Next();
}
}

this.Invoke(new MethodInvoker(AddData)); //Post a message to the main
thread.
Thread.Sleep(200);
}
}

private void AddData() //Receive message from another thread and add row
to the dataset
{
//This one works in the main thread.
lock(this)
{
if(this.dr != null)
this.myDataset.MyTable.Rows.Add(dr);
this.dr = null;
}
}
//-------------------------end of--------------------------------

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #4

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

Similar topics

1
by: ahaideb | last post by:
I have a table (relation) in my database: --------------- | parent | child | --------------- | 1 | 2 | | 1 | 3 | | 2 | 4 | | 2 | 5 ...
13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
6
by: Edwinah63 | last post by:
Hi everyone, could someone give me some thoughts on the best way to manage mdi parent and child forms? in vb6 i could scroll through the forms collection and determine which forms were...
1
by: Aaron Smith | last post by:
I have a parent table that has one child table. The parent has a single field (ID, AutoIncrement, Seed 0, Step -1 in the DataSet, Seed 1, step 1, in DataSource). The child is linked to this ID...
10
by: Goran Djuranovic | last post by:
Hi all, Does anyone know how to declare a variable in a class to be accessible ONLY from a classes instantiated within that class? For example: ************* CODE ***************** Public...
0
by: Innova | last post by:
Hi, We are working on a gridview inside the gridview (parent-child) scenario. The data of child grid will depend on the data of parent. Objectives: 1.Add new row in parent grid after each row...
4
by: mikemiller.innova | last post by:
In Visual Studio 2005 SP1, I added a DataSet item into my project. I added 3 tables from SQL that have data and relationships. I added 2 lookup columns (lkp) to the DllVersions table in the...
3
by: G .Net | last post by:
Hi Everybody I was wondering if anybody could help me with something that has been bothering me for some time. Basically, it is a problem I encountered some time ago with DataSets. I found a...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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
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,...

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.