PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
No value given for one or more required parameters
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
No value given for one or more required parameters
![]() |
No value given for one or more required parameters |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
I created a button in order to delete all the records at once in a gridview. But i get the error: No value given for one or more required parameters Thanks André The aspx file contains: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="..." .... </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" .... </asp:GridView> <input id="Button1" type="submit" runat="server" value="Cancel all" /> The code-behind contains: Protected Sub Button1_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.ServerClick x="this value" SqlDataSource1.SelectParameters.Add("param1", x) SqlDataSource1.DeleteCommand = "delete from mytable where field1 = @param1" SqlDataSource1.DeleteCommandType = SqlDataSourceCommandType.Text SqlDataSource1.Delete() End Sub |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Andre,
You have to faces, one is to delete the rows from your datasource The second is to update that datasource to your database. You are trying to do that in one time. But I don't not really know if you want to delete them in the database according to your text. Cor "André" <sdsds@sds.sdf> schreef in bericht news:%23wOzkwkkGHA.3512@TK2MSFTNGP03.phx.gbl... > Hi, > > I created a button in order to delete all the records at once in a > gridview. > But i get the error: No value given for one or more required parameters > Thanks > André > > The aspx file contains: > <asp:SqlDataSource ID="SqlDataSource1" runat="server" > ConnectionString="..." > ... > </asp:SqlDataSource> > > <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" > ... > </asp:GridView> > > <input id="Button1" type="submit" runat="server" value="Cancel all" /> > > The code-behind contains: > Protected Sub Button1_ServerClick(ByVal sender As Object, ByVal e As > System.EventArgs) Handles Button1.ServerClick > x="this value" > SqlDataSource1.SelectParameters.Add("param1", x) > SqlDataSource1.DeleteCommand = "delete from mytable where field1 = > @param1" > SqlDataSource1.DeleteCommandType = SqlDataSourceCommandType.Text > SqlDataSource1.Delete() > End Sub > > > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Hi Cor, thanks for replying.
When a particular user starts the application, he sees in the gridview all his personal record. He can delete one row at the time by clicking on the 'delete' link in the gridview. There is a DeleteCommand in the aspx file. But i added a button in order to delete all his records at once. the code is in the code-behind file. The field after 'where ..' is his logon (gotten by the server-side Request.ServerVariables("remote_user"). So only all his own records will be deleted. I thought that passing a parameter with the right value would work ... Can you please tell me what to change in the code? Thanks André "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message news:uF4nFEqkGHA.1264@TK2MSFTNGP05.phx.gbl... > Andre, > > You have to faces, one is to delete the rows from your datasource > The second is to update that datasource to your database. > > You are trying to do that in one time. But I don't not really know if you > want to delete them in the database according to your text. > > Cor > > > "André" <sdsds@sds.sdf> schreef in bericht > news:%23wOzkwkkGHA.3512@TK2MSFTNGP03.phx.gbl... > > Hi, > > > > I created a button in order to delete all the records at once in a > > gridview. > > But i get the error: No value given for one or more required parameters > > Thanks > > André > > > > The aspx file contains: > > <asp:SqlDataSource ID="SqlDataSource1" runat="server" > > ConnectionString="..." > > ... > > </asp:SqlDataSource> > > > > <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" > > ... > > </asp:GridView> > > > > <input id="Button1" type="submit" runat="server" value="Cancel all" /> > > > > The code-behind contains: > > Protected Sub Button1_ServerClick(ByVal sender As Object, ByVal e As > > System.EventArgs) Handles Button1.ServerClick > > x="this value" > > SqlDataSource1.SelectParameters.Add("param1", x) > > SqlDataSource1.DeleteCommand = "delete from mytable where field1 = > > @param1" > > SqlDataSource1.DeleteCommandType = SqlDataSourceCommandType.Text > > SqlDataSource1.Delete() > > End Sub > > > > > > > > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
I found it:
SqlDataSource1.DeleteCommand = "delete from mytable where field1 ='" & x & "'" "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message news:uF4nFEqkGHA.1264@TK2MSFTNGP05.phx.gbl... > Andre, > > You have to faces, one is to delete the rows from your datasource > The second is to update that datasource to your database. > > You are trying to do that in one time. But I don't not really know if you > want to delete them in the database according to your text. > > Cor > > > "André" <sdsds@sds.sdf> schreef in bericht > news:%23wOzkwkkGHA.3512@TK2MSFTNGP03.phx.gbl... > > Hi, > > > > I created a button in order to delete all the records at once in a > > gridview. > > But i get the error: No value given for one or more required parameters > > Thanks > > André > > > > The aspx file contains: > > <asp:SqlDataSource ID="SqlDataSource1" runat="server" > > ConnectionString="..." > > ... > > </asp:SqlDataSource> > > > > <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" > > ... > > </asp:GridView> > > > > <input id="Button1" type="submit" runat="server" value="Cancel all" /> > > > > The code-behind contains: > > Protected Sub Button1_ServerClick(ByVal sender As Object, ByVal e As > > System.EventArgs) Handles Button1.ServerClick > > x="this value" > > SqlDataSource1.SelectParameters.Add("param1", x) > > SqlDataSource1.DeleteCommand = "delete from mytable where field1 = > > @param1" > > SqlDataSource1.DeleteCommandType = SqlDataSourceCommandType.Text > > SqlDataSource1.Delete() > > End Sub > > > > > > > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

