how to execute the DeleteCommand in code-behind?

P

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
 
P

phil

So obvious ...
Many thanks

Riki said:
SqlDataSource1.Delete()

--

Riki

phil said:
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
 

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

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top