开发者

Updating/Inserting is not supported by data source

I've been making my first ASP.NET Visual Studio website and I have just started working with databases, I've made a table and a backoffice page for me to control the content of my table.

This page follows the following rules:

-> I've added the SQLDataSource and configured.

-> I've added a gridview to see my content and configured it to my SQLDataSource, here I've added the Edit/Delete options.

-> I've added a DetailsView configured to my SWLDataSource, here I've added New option (to create new entries in my table)

My database has the id column set as primary key (data type=int; allow nulls=not checked)

Every time I try to update my data base through this backoffice page I get the following error:

Updating is not supported by data source 'SqlDataSource1' unless UpdateCommand is specified. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: Updating is not supported by data source 'SqlDataSource1' unless UpdateCommand is specified.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NotSupportedException: Updating is not supported by data source 'SqlDataSource1' unless UpdateCommand is specified.]

System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) +1644420

System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) +92

开发者_运维技巧 System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32 rowIndex, Boolean causesValidation) +907

System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +704

System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95

System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37

System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +123

System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37

System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118

System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

I could really use some help here!


The errormessage says it all : 'Updating is not supported by data source 'SqlDataSource1' unless UpdateCommand is specified.'. You have to assign sql code or the name of a stored procedure to the property UpdateCommand so that the SqlDataSource knows how to handle your update.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜