That is true....
But you can also set up explicit triggers for OnDelete events or you can
.....
I was just giving the two easiest methods. Now, don't get me wrong, I think
that using stored procedures is important whenever interacting with a
database management system to pull data. It is faster than sql delete
statements and it removes the risk of a malicious user imbedding sql into
your query. But, even when using a stored procedure to delete records from
a parent table, I have found that having the relation set up to
automatically delete child rows is faster and is, IMHO, better design. When
you have strict composition relationships, it only makes sense to cascade
updates and deletes.
ian
"Kathleen Dollard" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Ian,
>
> Those are certainly two valid options, but they are not the only options.
> You can issue explicit deletes via stored proc or TSQL for the chlidren
> before each parent record is deleted.
>
> --
> Kathleen (MVP-VB)
>
>
>
> "Ian Phillips" <(E-Mail Removed)> wrote in message
> news:BhPWa.14$(E-Mail Removed)...
> > If you are unwilling to load the tables into the dataset, you will have
to
> > add the logic into the database itself. You can do that with a
cascading
> > delete rule as discussed in option 1 of my initial post.
> >
> > If you want all your cascading to be done in the app and not the RDBMS,
> then
> > you will have to at least load the rows for the records that will have
to
> be
> > deleted. you can put a select clause into the sql for the selectCommand
> so
> > only the rows you are going to delete will be loaded. You need to
update
> > the sales table before you update the titles table in this process.
> >
> > HTH,
> >
> > ian
> >
> > "Jorge" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Thanks Ian,
> > >
> > > I will try the second option but, can i do that if my data set has
> > > only one data table? I wouldn't like to load the "sales" table on the
> > > data set (or is required?)
> > >
> > > I have tried de FillSchema method to create just the schema of the
> > > "sales" table, with no data rows. After that I created a data relation
> > > but my code still not working. This is a part of my code :
> > >
> > > ----------
> > > adapter = New SqlDataAdapter("SELECT * FROM titles", conexion)
> > > cmdBuilder = New SqlCommandBuilder(adapter)
> > >
> > > dset = New DataSet()
> > > adapter.Fill(dset, "titles")
> > >
> > > adapter.FillSchema(dset, SchemaType.Source, "sales")
> > >
> > > dset.Relations.Add("Titles_Sales", _
> > > dset.Tables("titles").Columns("title_id"), _
> > > dset.Tables("sales").Columns("title_id"))
> > > ----------
> > >
> > > Then when I delete a data row here, a exception is thrown :
> > >
> > > dset.Tables(0).Rows(index).Delete()
> > > adapter.Update(dset, "titles")
> > >
> > >
> > > Regards!
> > >
> > >
> > > "Ian Phillips" <(E-Mail Removed)> wrote in message
> > news:<2EsWa.4$(E-Mail Removed)>...
> > > > You will need to do one of two things:
> > > >
> > > > 1. Cascade deletes in your database so that,when you update the
> database
> > > > with the dataset modifications, the child rows are deleted as well.
> > > >
> > > > 2. Add in the other, related tables into the dataset and add a
cascade
> > > > delete rules for the dataset relations.
> > > >
> > > > In the second case, you will need to make sure that the child tables
> are
> > > > updated to the database before you update the parent.
> > > >
> > > > HTH,
> > > > ian
> > > >
> > > >
> > > > "Jorge" <(E-Mail Removed)> wrote in message
> > > > news:(E-Mail Removed)...
> > > > > Hello all!,
> > > > >
> > > > > I have a dataset with just one DataTable : "titles" (using pubs
> > > > > database). I want to delete a specific DataRow, the problem is
that
> > > > > "titles" is related with the table "sales" on the field
"title_id",
> > > > > and when I try to delete the record, ADO.NET throws me an
exception
> > > > > ...
> > > > >
> > > > > Dim table As DataTable = dataset.Tables("titles")
> > > > > table.Rows(0).Delete()
> > > > > dataadapter.Update(dataset, "titles") 'error!
> > > > >
> > > > >
> > > > > I know I can to create DataRelations between DataTables, but in
this
> > > > > case I just have one DataTable. How can I delete the related
records
> > > > > too? Do I need to use a Command object before the Delete method??
> > > > >
> > > > > I'm confused! ...
> > > > >
> > > > > Any suggestion will be appreciated ...
> > > > >
> > > > > Robert
> >
> >
>
>
|