B
Bernie Yaeger
Hi Yoramo,
Glad you got it to work. I don't know if I can explain what you are
observing. The wizard will add all kinds of mapping statements and xml
statements, but I'm not sure what they do and ultimately how they work.
Bernie
Glad you got it to work. I don't know if I can explain what you are
observing. The wizard will add all kinds of mapping statements and xml
statements, but I'm not sure what they do and ultimately how they work.
Bernie
yoramo said:Hi Bernie
Yes, it works!! I guess my problem was that I added a row directly from
the DataGrid and I did not initialize the fields.
I wrote:
DataRow aRow = dataSetGen11.Tables["Stam"].NewRow() ;
dataSetGen11.Tables["Stam"].Rows.Add(aRow) ;
Now I have initialized and it works just fine.
I noticed another thing the wizard generated statements added a longer
statement with all kinds of additional conditions, when I removed all the
conditions it has succeeded.
So I went back to catch the errors and to handle them but hear I found that
the error pointed at the ID that was fine the fields that failed where the
other fields.
Now I'm working with the minimized version of the insert and update
statements.
Can you explain?
Thanks
Yoramo
andBernie Yaeger said:Hi Yoramo,
OK, I think I know the problem.
I created a table in an access database. I named it stam and gave it 5
cols: id (autonumber), category (text), subcategory (text), numvalue
(number), adate (date/time). I made id the PK (primary key).
I then created a form with textboxes and one datetimepicker for inputan
'Add' button, no entry textbox of course for the id column. I used the
oledb data adapter wizard and created a dataset - and here's where your
problem probably is. When I developed the select statement I included ID,
even though it is not part of the form and not part of the insert statement,
because the dataadapter needs to have the PK col when it works with the
database to build the new row with the update statement. I then use this
code for the add button:
Dim rt As DataRow = Stamds1.Tables(0).NewRow
rt("category") = mcategory.Text
rt("subcategory") = msubcategory.Text
rt("numvalue") = mnumvalue.Text
rt("adate") = madate.Value
Stamds1.Tables(0).Rows.Add(rt)
Try
OleDbDataAdapter1.Update(Stamds1)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
This worked fine - added the row with no problem.
Let me know if this helps.
Bernie
VALUES
(?, built
by to
add