Click here to Skip to main content
15,311,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how in this code, without define paramter for update command it working?


    <asp:SqlDataSource ID="SqlDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ShopConnectionString %>" 
            DeleteCommand="DELETE FROM [Company] WHERE [ID] = @ID" 
            InsertCommand="INSERT INTO [Company] ([Title], [Address]) VALUES (@Title, @Address)" 
            
            SelectCommand="SELECT [ID], [Title], [Address] FROM [Company]"  
            UpdateCommand="UPDATE [Company] SET [Title] = @Title, [Address] = @Address WHERE [ID] = @ID">
            <deleteparameters>
                <asp:Parameter Name="ID" Type="Int64" />    
            </deleteparameters>

            <%--<updateparameters>
                <asp:Parameter Name="Title" Type="String" />
                <asp:Parameter Name="Address" Type="String" />
                <asp:Parameter Name="ID" Type="Int64" />
            </updateparameters>
--%>
            <insertparameters>
                <asp:Parameter Name="Title" Type="String" />
                <asp:Parameter Name="Address" Type="String" />
            </insertparameters>
Posted
Updated 1-May-11 23:22pm
v4
Comments
Sandeep Mewara 2-May-11 5:24am
   
Not clear. What are you trying to say/ask?
[no name] 2-May-11 5:48am
   
i comment update parameter update command,But it work correctly?how working it without specifying parameter ?

1 solution

It depends on what you want to do, see Using Parameters with Data source[^]
More than likely you want to update from controls for the Title / name:

XML
<Updateparameters>
  <asp:ControlParameter Name="Title" Type="String" controlid="DropDownListTitle" propertyname="SelectedValue"/>
  <asp:ControlParameter Name="Address" Type="String" controlid="nameTextBox" propertyname="Text"/>

</updateparameters>

As for the ID, that depends very much how you have designed the form, but more it is probably you'll get it from ControlParameter as above or a FormParameter or a QueryStringParameter.Examples are available in the link above.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900