asp.net - SqlDataSource insert error - too many arguments -
i want insert row infragistics grid. has 2 columns, id , name. both bound. when insert want use name column parameter. when use both, insertion works. have id parameter don't use because identity column. when use 'name', error, many arguments stored procedure.
this markup:
<ig:webhierarchicaldatagrid runat="server" height="600px" width="875px" clientidmode="static" autogeneratebands="false" autogeneratecolumns="false" datakeyfields="id" datamember="sqldatasource9_defaultview" stylesetname="windows7" id="wdgprivileges" datasourceid="webhierarchicaldatasource7" key="sqldatasource9_defaultview"> <columns> <ig:bounddatafield datafieldname="id" key="id" hidden="true"> <header text="id" /> <header text="id" /> </ig:bounddatafield> <ig:bounddatafield datafieldname="name" key="name" width="95%"> <header text="name" /> <header text="name" /> </ig:bounddatafield> </columns> </ig:webhierarchicaldatagrid> <asp:sqldatasource id="sqldatasource13" runat="server" connectionstring="<%$ connectionstrings %>" selectcommand="getprivilege" selectcommandtype="storedprocedure" updatecommand="setprivilege" updatecommandtype="storedprocedure" insertcommand="insprivilege" insertcommandtype="storedprocedure"> <updateparameters> <asp:parameter name="id" type="int32" /> <asp:parameter name="name" type="string" /> </updateparameters> <insertparameters> <asp:parameter name="name" type="string" /> </insertparameters> </asp:sqldatasource>
my stored procedure:
procedure [dbo].[insprivilege] @name varchar(50) begin insert privilege ([name], lastupdate) values (@name, getdate()) end
i need id bound update sql command.
do have use parameter in insert , not use it?
update
<ig:webhierarchicaldatasource id="webhierarchicaldatasource7" runat="server"> <dataviews> <ig:dataview id="sqldatasource9_defaultview" datamember="defaultview" datasourceid="sqldatasource13" /> </dataviews> </ig:webhierarchicaldatasource>
update update , select stored procedure info...
<asp:sqldatasource id="sqldatasource13" runat="server" connectionstring="<%$ connectionstrings %>" selectcommand="getprivilege" selectcommandtype="storedprocedure" updatecommand="setprivilege" updatecommandtype="storedprocedure" insertcommand="dminsprivilege" insertcommandtype="storedprocedure"> <updateparameters> <asp:parameter name="id" type="int32" /> <asp:parameter name="name" type="string" /> </updateparameters> <insertparameters> <asp:parameter name="id" type="int32" defaultvalue="0" /> <asp:parameter name="name" type="string" /> </insertparameters> </asp:sqldatasource>
select stored procedure:
procedure [dbo].[getprivilege] begin select id, [name] privilege (nolock) end
update stored procedure:
procedure [dbo].[setprivilege] @id int, @name varchar(50) begin update privilege set [name] = @name, lastupdate = getdate() id = @id end
error message: [sqlexception]: procedure or function insprivilege has many arguments specified.
i found out problem...it not sqldatasource infragistics control requires bound fields in queries. so, because id field bound, have use parameter in insert command though don't need it; kind of weird. else problem...i solved adding id parameter in insert statement , setting default value zero.
Comments
Post a Comment