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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top