Hi All,
I've taken a few steps forward on my project, but got caught by
another problem I can't figure out. Some help is needed please.
Please read the history of this app.
The application is now working fine,... EXCEPT when I go to add a
child row. It fails on the "TableAdapter2.Update(DataSet1.Table1)"
line, with the System.Data.OleDb.OleDbException error message:
"Index or key cannot contain a Null value."
A scaled down version of my add child row routine.
Dim nxCatRow As DataRow
' Add a new Category record
nxCatRow = DataSet1.Table2.NewRow
nxCatRow.Item("t2ProdGrp") = tbAddPG.Text
nxCatRow.Item("t2Cat") = tbAddCat.Text
nxCatRow.Item("tt2SubCat") = tbAddSubCat.Text
.... fill other fields.....
DataSet1.Table2.Rows.Add()
Try
TableAdapter2.Update(DataSet1.Table1)
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Exclamation, "Add a
Category Error - Cat Table Update")
End Try
DataSet1.Table2.AcceptChanges()
I think I'm mixed up with trying to add to the underlying dataset,
because I'm not going through and using the datarelation source of the
datagridview. But how do I do it???
Can somebody show me how to overcome this?
Thanks,
Hexman
Here's the History..................................................
I even started off with a new project and a blank form. In design
view I created a DataSet, 2 tables within the DataSet, 2
TableAdapters, and 2 BindingSources. One tableadapter and one
BindingSource for each table. The tables have the following key
structure:
Table1
PK t1Date
pk t1Part
pk t1WH
t1Cat
....other fields.....
Table2
PK t2ProdGrp
pk t2Cat
pk t2SubCat
....other fields.....
What I want to do is to scroll thru the items in Table1 and as a row
is selected to show only those rows in Table 2 with a matching
category (t1Cat = t2Cat).
Each row in Table1 has a t1Cat, there may be up to 50 or so Table2
matching Cat's. (We will manually be assigning sub-cats with this
app.)
In design view, I added a relation "PartsCats", parent key = t1Cat,
child key= t2Cat.
When I run the program, both DataGridViews get loaded and visible, but
no filtering of categories occurs in Table2. What am I missing?
-------------------------------------------------------------
Ricardo came up with the following answer to my problem:
>binding1.DataMember = "table1"
>binding1.DataSource = dataSet1
>grd1.DataSource = binding1
>
>binding2.DataMember = "PartsCats"
>binding2.DataSource = binding1
>grd2.DataSource = binding2
I only needed to change the last 3 lines using designer for the
binding source and the dgv properties for the DataGridView. It now
works fine.
Radenko Zec - 06 May 2006 20:13 GMT
You trying to update table and you havent enter information for primary key
or index,one value is null.
I hope that is solution.
> Hi All,
>
[quoted text clipped - 87 lines]
> binding source and the dgv properties for the DataGridView. It now
> works fine.
Hexman - 06 May 2006 22:28 GMT
I don't understand. Am I not filling the key fields with these
commands?
>> nxCatRow.Item("t2ProdGrp") = tbAddPG.Text
>> nxCatRow.Item("t2Cat") = tbAddCat.Text
>> nxCatRow.Item("tt2SubCat") = tbAddSubCat.Text
Should I be adding them elsewhere also???
Thanks for trying to aid me with this problem.
Hexman
>You trying to update table and you havent enter information for primary key
>or index,one value is null.
[quoted text clipped - 91 lines]
>> binding source and the dgv properties for the DataGridView. It now
>> works fine.