473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to execute the DeleteCommand in code-behind?

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
2 7323
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Nanda | last post by:
hi, I am trying to generate parameters for the updatecommand at runtime. this.oleDbDeleteCommand1.CommandText=cmdtext; this.oleDbDeleteCommand1.Connection =this.oleDbConnection1;...
0
by: Christopher Weaver | last post by:
Using VS 2003: My odbcDataAdapter.DeleteCommand.CommandType is StoredProcedure. The call is returning an error indicating that my SP doesn't return a value. Does it have to? I don't need one,...
2
by: Peter Afonin | last post by:
Hello: I'm deleteing data using Datagrid, then rebind it. For some reason ItemDataBound event doesn't fire after DeleteCommand. Why is this? Is it by design, or I'm missing something? I have...
4
by: Rodger Dusatko | last post by:
After entering the sql statement da.deletecommand.commandtext = "Delete from Users where username = @username" I set the parameter to the username I wish to delete. This successfully deletes the...
1
by: John | last post by:
Hi guys, could u pls give me simple code of how to use the DeleteCommand of an adapter to delete a row!!!? Thanks -- Regads, Rochdi
4
by: Nathan Sokalski | last post by:
I have a DataList that has an Button as one of the controls in it's ItemTemplate. The Button has a CommandName="delete" attribute, but when I click it the DeleteCommand event doesn't even get...
0
by: | last post by:
Hi, How to add the DeleteCommand="delete from table where ..." related to a gridview in VB.Net, because i have no tag <asp:SqlDataSource >? This is the content of file grid.asp:...
1
by: Jason Barnett | last post by:
I dropped a DataGrid control onto a Web UserControl (.ascx) and added columns for Editing and Deleting data. At first, I had everything working; when the edit button was clicked the row entered...
0
by: sherifffruitfly | last post by:
Hi, I'm deleting a bunch of records from my DB, and they actually DO get deleted (as I verify by looking afterwards). But then I get the exception in the subject line. Isn't it weird that all of...
1
by: renatois | last post by:
DeleteCommand in SqlDataSource using DetailsView Hi guys, Figure that: - I have two related tables by IDName: 1 - table Name (fields: IDName, Name) 2 - table Products (fields: IDProduct,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.