asp.net - GridView update causes "incorrect syntax near 'nvarchar'" error -


i have major problem when trying use update in gridview. code below, once click 'edit', option change 'kpi' name , 'current target'. but, once click 'update', error message:

incorrect sysntax near 'nvarchar'

here markup:

<p>     <br />     <asp:dropdownlist id="groupselection" runat="server" datasourceid="group" datatextfield="fcstgroup"         datavaluefield="fcstgroup">     </asp:dropdownlist> </p> <p>     <asp:gridview id="gridview2" runat="server" datasourceid="sqldatasource1">         <columns>             <asp:commandfield showeditbutton="true" />         </columns>     </asp:gridview> </p> <p>     <asp:sqldatasource id="sqldatasource1" runat="server" connectionstring="<%$ connectionstrings:wfmconnectionstring3 %>"         selectcommand="select                              case _parameter.name kpi,                             [target]*100 [current target]                             _parameter inner join _reporting_group                             on _parameter.reporting_group = _reporting_group.id                              _reporting_group.name = @wg "  updatecommand="update _parameter set target = .80                                 reporting_group = (select id _reporting_group name = @wg)                                 , name = 'nco_i_e' ">         <selectparameters>             <asp:controlparameter controlid="groupselection" name="wg" propertyname="selecteditem.text" />         </selectparameters>         <updateparameters>             <asp:controlparameter controlid="groupselection" name="wg" propertyname="selecteditem.text" />         </updateparameters>     </asp:sqldatasource> </p> <asp:sqldatasource id="group" runat="server" connectionstring="<%$ connectionstrings:wfmconnectionstring3 %>"     selectcommand=" select     distinct _reporting_group.name fcstgroup         dbo._metrics inner join                     dbo._reporting_group on dbo._metrics.reporting_group = dbo._reporting_group.id "> </asp:sqldatasource> 

i'm guessing problem update command, working correctly when ran in sql:

updatecommand="update _parameter set target = .80                                 reporting_group = (select id _reporting_group name = @wg)                                 , name = 'nco_i_e' "> 

note that, @ moment, update command using fixed set 'target' value , fixed 'name' value. eventually, need use value entered in 'current target' , kpi value. but, once can figure out why i'm getting 'nvarchar' error message.

if can spot issue is, appreciate it.

the first thing jumps out @ me should change updateparameter this:

<asp:controlparameter controlid="groupselection" name="wg" propertyname="selecteditem.text" /> 

selecteditem.text not valid property (the .text should capitalized).

other things possibly cause problem data types in sql. if "target" column can't accept value of .80, or if "name" value can't accept whatever you're selecting in "groupselection" dropdownlist, possibly cause type of syntax error.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -