|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to execute the DeleteCommand in code-behind?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 SqlDataSource1.Delete()
-- Show quoteHide quoteRiki "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 > > 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 > > > > > >
Passing "Style" along to constituent controls
How to add controls to panel in asp.net 2.0 DropDownList - Is it Possible to get the TextField Contents how to DataBind TreeView expanded property? DropDownList problem Gridview and Filtering problem Need to keep source window open after Hyperlink is activated Postback problem with usercontrol in usercontrol drop down list Threading in ASP.NET 2.0 web parts |
|||||||||||||||||||||||