Need basic direction - parent/child Insert help

mmeier

Member
Joined
Jun 25, 2007
Messages
8
Programming Experience
10+
I have a windows forms ap functioning with a form of -Checks- (parent) and -Expense Splits- (child) datagridview. All is working well. Adds, deletes, etc.

I need to add this functionality. When the user select a -Payee- in the parent, I need to find the amount of the last check written to this payee. Then get the splits (children) of that last check. This would be displayed immediatly after selecting the payee in the form and datagridview. Then the operator can accept or edit.

I need basic direction in the following area. Do I use a sqldatareader to get this information and add rows to my datatables, -or- look through the datatables the form and datagridview is using, -or- some other method?

Being new to vb.net, ado.net, I'm don't know what would be the suggested method.

Thanks for any direction you may point me.
 
It may be easier if you can post a screenshot of your form layout, as I can't quite get what you are trying to do in my head.

- are you using SQL database, or another data source?


Do I use a sqldatareader to get this information and add rows to my datatables

DataReaders do as they say...they read data - you can't add rows this way :D

If you are currently loading your data into DataSets, then you use this.
 
Using SQL 2000.

Sorry, new to posting in forums. How do I post a screen shot here? I'd be happy to.

I'll try to describe it further.

Top half of form looks like a blank check. (parent table)

The bottom half of the form is a datagridview of how parent check is split up. (Children)

In the top half (check) part of the form - when the user selects a payee, I go to SQL and get the last check that was wrote to this payee and then the related spits of that check.

Now I want to populate the datagrid view with the splits from the last time we paid this person. Like setting the defaults to be the last payment to this payee.

Since I posted this question, I read the splits from sql and in code, inserted them into the check splits (children) datatable. I seem to be making progress, but I don't know if I'm approaching this the proper way.

Any - hey dummy - why you doing it that way is appreciated!

Thanks,

Mike
 
I have a windows forms ap functioning with a form of -Checks- (parent) and -Expense Splits- (child) datagridview. All is working well. Adds, deletes, etc.

I need to add this functionality. When the user select a -Payee- in the parent, I need to find the amount of the last check written to this payee.

Payee doesnt seem to be part of this relationship. One Payee can have many checks, which kinda infers that payee is a parent in another table. Can you make your post more clear?

Perhaps you want to:

SELECT * FROM checks WHERE payee = :pAYEE ORDER BY check_date DESC

:pAYEE is an oracle parameter. If you dont use oracle, adjust it for your database (? access, @PAYEE sqlserver, ?PAYEE mysql)

The top row is the most recent check

Then get the splits (children) of that last check.

expensesTableAdapter.FillByWhateverID(expensesDataTable, checksDataTable.Rows(0).WHATEVER_ID)


I need basic direction in the following area. Do I use a sqldatareader to get this information and add rows to my datatables, -or- look through the datatables the form and datagridview is using, -or- some other method?
Read the DW2 link in my sig, Creating a Form to Search Data
It shows how to make a tableadapter have a query that is parameterized
 
DataReaders do as they say...they read data - you can't add rows this way :D
Well, you can:

VB.NET:
while reader.Next
  myDatatable.AddXXXRow(reader(0), reader(1) ... reader(99))
end while

But then youre making a bad job of reinventing a perfectly good tableadapter
 
Any - hey dummy - why you doing it that way is appreciated!

Thanks,

Mike

Post your project, as a zipped attachment, DO NOT INCLUDE THE BIN OR OBJ FOLDERS IN YOUR ZIP FILE

THis way we can downlaod and look to see if we should be saying hey dummy , dont do it like that!
 
Back
Top