473,883 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.showdialo g" that displayed the win form to
begin with:

This is the 1st error after about 10 rows added
System.NullRefe renceException - 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 1487
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******@onlin e.microsoft.com > wrote in message
news:Fl******** ******@cpmsftng xa07.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 misunderstandin g. I'd like to share the
following information with you:

I believe that the exception NullReferenceEx ception 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.Dat aRow dr;

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

dataGrid.DataSo urce = myDataset;
dr = null;

ThreadStart threadStart = new ThreadStart(lis tenThread);
Thread thread = new Thread(threadSt art);
thread.IsBackgr ound = true;
thread.Start();
}

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

this.Invoke(new MethodInvoker(A ddData)); //Post a message to the main
thread.
Thread.Sleep(20 0);
}
}

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.Ad d(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
9129
by: ahaideb | last post by:
I have a table (relation) in my database: --------------- | parent | child | --------------- | 1 | 2 | | 1 | 3 | | 2 | 4 | | 2 | 5 | | 3 | 6 |
13
7426
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 created forms for both those tables, and inserted the child table form into the master table form as a subform. It works just as it is supposed to, in that I can create a new master record, and then add detail records.
6
9434
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 open/closed and their current state. now i can't. before i didn't have to declare numerous named instances each time i loaded or unloaded a form.
1
2221
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 column in the parent. I have the parent fields in textboxes and the child is a DataGrid. When I add a new parent record, then go to add child records, I am getting an exception that says, "ForeignKeyConstraint requires the child key values (0) to...
10
19642
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 Class Parent '*** HOW TO DECLARE IT *** Dim Age As String = "1/1/2000"
0
8570
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 and add child grid into that row because the columns in child grid are same as parent grid and we want to align them with the cols of parent grid. 2. If there is data for child grid we show a plus image in the parent row (in the row above the...
4
1896
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 dataset ProjectID
3
2418
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 solution (which I will refer to later) but I have a gut feeling that there must be an easier way to do it. In order I can explain the problem, consider the following: Suppose I have a DataSet which has two tables "Customers" and "Orders". I set up...
3
18724
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, working with complex reports is tricky Assumption: Reader of this article have basic knowledge of creating data reports. Creating a Parent-Child Command and create a DataReport Suppose we have a database called company with two tables ...
0
9948
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9798
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
11164
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10864
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
10422
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7980
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
7137
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();...
2
4230
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3242
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.