GridView Update

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Looch

    GridView Update

    Hi,

    I'm filling a GridView with a simple sproc select statement. I'm
    trying to use the Update tab to create an update statement and using
    the following:

    Update Shipping_Reques ts
    Set Shipped = @Shipped

    The Shipped column is a bit type column that is returned in the
    initial sproc call to fill the GridView. I'm getting the error:

    "Incorrect syntax near 'nvarchar'" when trying to update the row.

    The stack trace is below. This seems like a no brainer but I can't
    seem to get it to work. Any ideas? Thanks in advance.


    [SqlException (0x80131904): Incorrect syntax near 'nvarchar'.]
    System.Data.Sql Client.SqlConne ction.OnError(S qlException exception,
    Boolean breakConnection ) +859322
    System.Data.Sql Client.SqlInter nalConnection.O nError(SqlExcep tion
    exception, Boolean breakConnection ) +736198

    System.Data.Sql Client.TdsParse r.ThrowExceptio nAndWarning(Tds ParserStateObje ct
    stateObj) +188
    System.Data.Sql Client.TdsParse r.Run(RunBehavi or runBehavior,
    SqlCommand cmdHandler, SqlDataReader dataStream,
    BulkCopySimpleR esultSet bulkCopyHandler , TdsParserStateO bject
    stateObj) +1959
    System.Data.Sql Client.SqlComma nd.FinishExecut eReader(SqlData Reader
    ds, RunBehavior runBehavior, String resetOptionsStr ing) +149

    System.Data.Sql Client.SqlComma nd.RunExecuteRe aderTds(Command Behavior
    cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
    async) +903
    System.Data.Sql Client.SqlComma nd.RunExecuteRe ader(CommandBeh avior
    cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
    method, DbAsyncResult result) +132

    System.Data.Sql Client.SqlComma nd.InternalExec uteNonQuery(DbA syncResult
    result, String methodName, Boolean sendToPipe) +415
    System.Data.Sql Client.SqlComma nd.ExecuteNonQu ery() +135

    System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteDbCommand (DbCommand
    command, DataSourceOpera tion operation) +401

    System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteUpdate(ID ictionary
    keys, IDictionary values, IDictionary oldValues) +721
    System.Web.UI.D ataSourceView.U pdate(IDictiona ry keys, IDictionary
    values, IDictionary oldValues, DataSourceViewO perationCallbac k
    callback) +78
    System.Web.UI.W ebControls.Grid View.HandleUpda te(GridViewRow row,
    Int32 rowIndex, Boolean causesValidatio n) +1215
    System.Web.UI.W ebControls.Grid View.HandleEven t(EventArgs e, Boolean
    causesValidatio n, String validationGroup ) +858
    System.Web.UI.W ebControls.Grid View.OnBubbleEv ent(Object source,
    EventArgs e) +95
    System.Web.UI.C ontrol.RaiseBub bleEvent(Object source, EventArgs
    args) +35
    System.Web.UI.W ebControls.Grid ViewRow.OnBubbl eEvent(Object source,
    EventArgs e) +117
    System.Web.UI.C ontrol.RaiseBub bleEvent(Object source, EventArgs
    args) +35
    System.Web.UI.W ebControls.Link Button.OnComman d(CommandEventA rgs e)
    +115
    System.Web.UI.W ebControls.Link Button.RaisePos tBackEvent(Stri ng
    eventArgument) +163

    System.Web.UI.W ebControls.Link Button.System.W eb.UI.IPostBack EventHandler.Ra isePostBackEven t(String
    eventArgument) +7
    System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
    sourceControl, String eventArgument) +11
    System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
    +174
    System.Web.UI.P age.ProcessRequ estMain(Boolean
    includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
    +5102
  • =?Utf-8?B?QW5nZWw=?=

    #2
    RE: GridView Update

    Your sql is not correct but I can't tell with out looking at your code. Post
    some code.

    I have working examples of the products table in Northwind and the sql looks
    like this
    "Update products set discontinued ='true'... this is working just fine and
    discontinued is a bit datatype.

    --
    aaa


    "Looch" wrote:
    Hi,
    >
    I'm filling a GridView with a simple sproc select statement. I'm
    trying to use the Update tab to create an update statement and using
    the following:
    >
    Update Shipping_Reques ts
    Set Shipped = @Shipped
    >
    The Shipped column is a bit type column that is returned in the
    initial sproc call to fill the GridView. I'm getting the error:
    >
    "Incorrect syntax near 'nvarchar'" when trying to update the row.
    >
    The stack trace is below. This seems like a no brainer but I can't
    seem to get it to work. Any ideas? Thanks in advance.
    >
    >
    [SqlException (0x80131904): Incorrect syntax near 'nvarchar'.]
    System.Data.Sql Client.SqlConne ction.OnError(S qlException exception,
    Boolean breakConnection ) +859322
    System.Data.Sql Client.SqlInter nalConnection.O nError(SqlExcep tion
    exception, Boolean breakConnection ) +736198
    >
    System.Data.Sql Client.TdsParse r.ThrowExceptio nAndWarning(Tds ParserStateObje ct
    stateObj) +188
    System.Data.Sql Client.TdsParse r.Run(RunBehavi or runBehavior,
    SqlCommand cmdHandler, SqlDataReader dataStream,
    BulkCopySimpleR esultSet bulkCopyHandler , TdsParserStateO bject
    stateObj) +1959
    System.Data.Sql Client.SqlComma nd.FinishExecut eReader(SqlData Reader
    ds, RunBehavior runBehavior, String resetOptionsStr ing) +149
    >
    System.Data.Sql Client.SqlComma nd.RunExecuteRe aderTds(Command Behavior
    cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
    async) +903
    System.Data.Sql Client.SqlComma nd.RunExecuteRe ader(CommandBeh avior
    cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
    method, DbAsyncResult result) +132
    >
    System.Data.Sql Client.SqlComma nd.InternalExec uteNonQuery(DbA syncResult
    result, String methodName, Boolean sendToPipe) +415
    System.Data.Sql Client.SqlComma nd.ExecuteNonQu ery() +135
    >
    System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteDbCommand (DbCommand
    command, DataSourceOpera tion operation) +401
    >
    System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteUpdate(ID ictionary
    keys, IDictionary values, IDictionary oldValues) +721
    System.Web.UI.D ataSourceView.U pdate(IDictiona ry keys, IDictionary
    values, IDictionary oldValues, DataSourceViewO perationCallbac k
    callback) +78
    System.Web.UI.W ebControls.Grid View.HandleUpda te(GridViewRow row,
    Int32 rowIndex, Boolean causesValidatio n) +1215
    System.Web.UI.W ebControls.Grid View.HandleEven t(EventArgs e, Boolean
    causesValidatio n, String validationGroup ) +858
    System.Web.UI.W ebControls.Grid View.OnBubbleEv ent(Object source,
    EventArgs e) +95
    System.Web.UI.C ontrol.RaiseBub bleEvent(Object source, EventArgs
    args) +35
    System.Web.UI.W ebControls.Grid ViewRow.OnBubbl eEvent(Object source,
    EventArgs e) +117
    System.Web.UI.C ontrol.RaiseBub bleEvent(Object source, EventArgs
    args) +35
    System.Web.UI.W ebControls.Link Button.OnComman d(CommandEventA rgs e)
    +115
    System.Web.UI.W ebControls.Link Button.RaisePos tBackEvent(Stri ng
    eventArgument) +163
    >
    System.Web.UI.W ebControls.Link Button.System.W eb.UI.IPostBack EventHandler.Ra isePostBackEven t(String
    eventArgument) +7
    System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
    sourceControl, String eventArgument) +11
    System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
    +174
    System.Web.UI.P age.ProcessRequ estMain(Boolean
    includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
    +5102
    >

    Comment

    • David C

      #3
      Re: GridView Update

      Try using 1 for true and 0 for false conditions.
      "Looch" <lucianoj2005@y ahoo.comwrote in message
      news:ef2bb5ad-63f3-4178-8642-e15143a25780@i2 9g2000prf.googl egroups.com...
      Hi,
      >
      I'm filling a GridView with a simple sproc select statement. I'm
      trying to use the Update tab to create an update statement and using
      the following:
      >
      Update Shipping_Reques ts
      Set Shipped = @Shipped
      >
      The Shipped column is a bit type column that is returned in the
      initial sproc call to fill the GridView. I'm getting the error:
      >
      "Incorrect syntax near 'nvarchar'" when trying to update the row.
      >
      The stack trace is below. This seems like a no brainer but I can't
      seem to get it to work. Any ideas? Thanks in advance.
      >
      >
      [SqlException (0x80131904): Incorrect syntax near 'nvarchar'.]
      System.Data.Sql Client.SqlConne ction.OnError(S qlException exception,
      Boolean breakConnection ) +859322
      System.Data.Sql Client.SqlInter nalConnection.O nError(SqlExcep tion
      exception, Boolean breakConnection ) +736198
      >
      System.Data.Sql Client.TdsParse r.ThrowExceptio nAndWarning(Tds ParserStateObje ct
      stateObj) +188
      System.Data.Sql Client.TdsParse r.Run(RunBehavi or runBehavior,
      SqlCommand cmdHandler, SqlDataReader dataStream,
      BulkCopySimpleR esultSet bulkCopyHandler , TdsParserStateO bject
      stateObj) +1959
      System.Data.Sql Client.SqlComma nd.FinishExecut eReader(SqlData Reader
      ds, RunBehavior runBehavior, String resetOptionsStr ing) +149
      >
      System.Data.Sql Client.SqlComma nd.RunExecuteRe aderTds(Command Behavior
      cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
      async) +903
      System.Data.Sql Client.SqlComma nd.RunExecuteRe ader(CommandBeh avior
      cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
      method, DbAsyncResult result) +132
      >
      System.Data.Sql Client.SqlComma nd.InternalExec uteNonQuery(DbA syncResult
      result, String methodName, Boolean sendToPipe) +415
      System.Data.Sql Client.SqlComma nd.ExecuteNonQu ery() +135
      >
      System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteDbCommand (DbCommand
      command, DataSourceOpera tion operation) +401
      >
      System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteUpdate(ID ictionary
      keys, IDictionary values, IDictionary oldValues) +721
      System.Web.UI.D ataSourceView.U pdate(IDictiona ry keys, IDictionary
      values, IDictionary oldValues, DataSourceViewO perationCallbac k
      callback) +78
      System.Web.UI.W ebControls.Grid View.HandleUpda te(GridViewRow row,
      Int32 rowIndex, Boolean causesValidatio n) +1215
      System.Web.UI.W ebControls.Grid View.HandleEven t(EventArgs e, Boolean
      causesValidatio n, String validationGroup ) +858
      System.Web.UI.W ebControls.Grid View.OnBubbleEv ent(Object source,
      EventArgs e) +95
      System.Web.UI.C ontrol.RaiseBub bleEvent(Object source, EventArgs
      args) +35
      System.Web.UI.W ebControls.Grid ViewRow.OnBubbl eEvent(Object source,
      EventArgs e) +117
      System.Web.UI.C ontrol.RaiseBub bleEvent(Object source, EventArgs
      args) +35
      System.Web.UI.W ebControls.Link Button.OnComman d(CommandEventA rgs e)
      +115
      System.Web.UI.W ebControls.Link Button.RaisePos tBackEvent(Stri ng
      eventArgument) +163
      >
      System.Web.UI.W ebControls.Link Button.System.W eb.UI.IPostBack EventHandler.Ra isePostBackEven t(String
      eventArgument) +7
      System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
      sourceControl, String eventArgument) +11
      System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
      +174
      System.Web.UI.P age.ProcessRequ estMain(Boolean
      includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
      +5102

      Comment

      Working...