another delete prob.

M

Marc Miller

I've read other posts concerning unsuccessful deletes, but I can't find
anything that tells me what is wrong
with my code. After I delete() the row in the dataset, the dataset is empty
and I get 0 as the value for
my 'isDel' variable. What am I doing that I shouldn't be doing, or
vice-a-versa?

Thanks for any help,
Marc Miller

Dim sr As New StringReader(CStr(viewstate("dsbldgdata1")))

DsBldgData1.ReadXml(sr)

..DsBldgData1.Tables("Profile").Rows(0).Delete()

SqlConnection1.Open()


Dim iDel As Integer

Try

iDel = SqlDataAdapter1.Update(DsBldgData1, "Profile")

Catch ex As Exception

errWindowShow(ex.message)

Finally

SqlConnection1.Close()

End Try
 
G

Guest

I am not sure what you are trying to do here. From your statement, I assume
you are attempting to update a database table, but I do not see where the
adapter actually gets connected to the database. With the naming, I assume
this was a drag and drop setup?

You are then reading in records from an XML file, deleting them and calling
Update(). As these are not records from the database itself, they will, at
best, be seen as added records that were deleted, essentially nulling out any
changes. If I am misunderstanding the code, please clue me in.

If your goal is to update the XML, delete the nodes and WriteXml() back to
the file. If you are updating a database, you need to reference rows there;
if this is not possible, you will have to write custom code to delete records.

Hope this helps.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
M

Marc Miller

Cowboy,

Thanks for your response. Yes (chagrin), it is a drag & drop. I'm sorry
that I
didn't show the connection for the dataadapter in the code.

What I was doing was preserving a dataset that was displayed in the form
from the Page_Load
event. If the user decides to delete the record, I then reload the dataset
from the
XML file.

What was missing from my code was adding a 'DsBldgData1.AcceptChanges()'
directly after the reload of the dataset and before the record.delete(). I
found
this by experimentation.

Thanks again,
Marc Miller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top