By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,993 Members | 1,947 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,993 IT Pros & Developers. It's quick & easy.

No value given for one or more required parameters

P: 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

Jun 17 '06 #1
Share this Question
Share on Google+
3 Replies


P: 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é" <sd***@sds.sdf> schreef in bericht
news:%2****************@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

Jun 18 '06 #2

P: 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]" <no************@planet.nl> wrote in message
news:uF**************@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é" <sd***@sds.sdf> schreef in bericht
news:%2****************@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


Jun 18 '06 #3

P: n/a
I found it:
SqlDataSource1.DeleteCommand = "delete from mytable where field1 ='" & x &
"'"

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:uF**************@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é" <sd***@sds.sdf> schreef in bericht
news:%2****************@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


Jun 18 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.