Home All Groups Group Topic Archive Search About

how to execute the DeleteCommand in code-behind?

Author
1 Jun 2006 1:37 PM
phil
Hi,

The connection and DeleteCommand of a gridview are defined in the aspx file
like this:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydb.mdb"
ProviderName="System.Data.OleDb"
DeleteCommand="delete from mytable where [nr] = @nr" >
</asp:SqlDataSource>

Now i created a button (button1) for deleting all records at once. So i
defined a new DeleteCommand in the code-behind. My problem is how to execute
that new command.
Look what i tried in the code-behind file:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
SqlDataSource1.DeleteCommand = "delete from mytable"
SqlDataSource1.DeleteCommandType = SqlDataSourceCommandType.Text
End Sub

I can't find an 'execute' or similar ...
Thanks fro helping
Phil

Author
1 Jun 2006 2:02 PM
Riki
SqlDataSource1.Delete()

--

Riki

Show quoteHide quote
"phil" <p**@sds.dc> wrote in message
news:uF1ZMCYhGHA.2456@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> The connection and DeleteCommand of a gridview are defined in the aspx
> file
> like this:
> <asp:SqlDataSource ID="SqlDataSource1" runat="server"
> ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=c:\mydb.mdb"
> ProviderName="System.Data.OleDb"
> DeleteCommand="delete from mytable where [nr] = @nr" >
> </asp:SqlDataSource>
>
> Now i created a button (button1) for deleting all records at once. So i
> defined a new DeleteCommand in the code-behind. My problem is how to
> execute
> that new command.
> Look what i tried in the code-behind file:
> Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> SqlDataSource1.DeleteCommand = "delete from mytable"
> SqlDataSource1.DeleteCommandType = SqlDataSourceCommandType.Text
> End Sub
>
> I can't find an 'execute' or similar ...
> Thanks fro helping
> Phil
>
>
Author
1 Jun 2006 2:47 PM
phil
So obvious ...
Many thanks

Show quoteHide quote
"Riki" <r***@bounce.com> wrote in message
news:OWWZ1NYhGHA.5088@TK2MSFTNGP02.phx.gbl...
> SqlDataSource1.Delete()
>
> --
>
> Riki
>
> "phil" <p**@sds.dc> wrote in message
> news:uF1ZMCYhGHA.2456@TK2MSFTNGP04.phx.gbl...
> > Hi,
> >
> > The connection and DeleteCommand of a gridview are defined in the aspx
> > file
> > like this:
> > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
> > ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data
> > Source=c:\mydb.mdb"
> > ProviderName="System.Data.OleDb"
> > DeleteCommand="delete from mytable where [nr] = @nr" >
> > </asp:SqlDataSource>
> >
> > Now i created a button (button1) for deleting all records at once. So i
> > defined a new DeleteCommand in the code-behind. My problem is how to
> > execute
> > that new command.
> > Look what i tried in the code-behind file:
> > Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> > SqlDataSource1.DeleteCommand = "delete from mytable"
> > SqlDataSource1.DeleteCommandType = SqlDataSourceCommandType.Text
> > End Sub
> >
> > I can't find an 'execute' or similar ...
> > Thanks fro helping
> > Phil
> >
> >
>
>