Re: another delete prob.

From: Marc Miller (mm1284_at_hotmail.com)
Date: 02/22/05


Date: Tue, 22 Feb 2005 11:21:38 -0500

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

"Cowboy (Gregory A. Beamer) - MVP" <NoSpamMgbworld@comcast.netNoSpamM> wrote
in message news:BE0F5FA9-823E-4FEC-B66F-DB906399C82E@microsoft.com...
> 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!
> ***************************
>
>
> "Marc Miller" wrote:
>
> > 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
> >
> >
> >



Relevant Pages

  • DataAdapter Not Updating
    ... If it connects it uses an OleDbCommand with an SQL String and the connection ... It does this for 6 DataTables, ... That all works fine including saving the DataSet to an XML file and if the ... update 4 of the DataTables from the DataBase. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Enterprise Library
    ... xml support i will add extar coding to my data access layer. ... by itself for my requirement reads Database connections from confg file.. ... pass connection informations as part of the code itself and use the common DB ... query an XML file so that I'm a little unsure about. ...
    (microsoft.public.dotnet.framework)
  • Drop drop strongly typed datasets.
    ... Is there a way to drag an xml file onto the designer and have it build the ... data tables for me (like I do with a database connection.)? ...
    (microsoft.public.data.ado)
  • Server Explorer
    ... connection to the server explorer and it correctly adds the connection ... and displays all the tables in the database that I added. ... In VS.Net 2003, we could drag ...
    (microsoft.public.dotnet.languages.csharp)
  • Server Explorer
    ... connection to the server explorer and it correctly adds the connection ... and displays all the tables in the database that I added. ... In VS.Net 2003, we could drag ...
    (microsoft.public.vsnet.general)