By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

how to execute the DeleteCommand in code-behind?

P: n/a
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
Jun 1 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
SqlDataSource1.Delete()

--

Riki

"phil" <pz*@sds.dc> wrote in message
news:uF**************@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

Jun 1 '06 #2

P: n/a
So obvious ...
Many thanks

"Riki" <ri**@bounce.com> wrote in message
news:OW**************@TK2MSFTNGP02.phx.gbl...
SqlDataSource1.Delete()

--

Riki

"phil" <pz*@sds.dc> wrote in message
news:uF**************@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


Jun 1 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.