Bonjour
je developpe avec visual studio et C#
je fait une petite appication et j'ai cette erreur si quelqu'un peut me dire de quoi il s'agit
volia l'erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
Erreur du serveur dans l'application '/Stock'.
--------------------------------------------------------------------------------
 
Impossible d'insérer une valeur explicite dans la colonne identité de la table 'STKMAGASIN' quand IDENTITY_INSERT est défini à OFF. 
Description : Une exception non gérée s'est produite au moment de l'exécution de la demande Web actuelle. Contrôlez la trace de la pile pour plus d'informations sur l'erreur et son origine dans le code. 
 
Détails de l'exception: System.Data.SqlClient.SqlException: Impossible d'insérer une valeur explicite dans la colonne identité de la table 'STKMAGASIN' quand IDENTITY_INSERT est défini à OFF.
 
Erreur source: 
 
 
Ligne 25 :         sourceMag.InsertParameters["MAGCODE"].DefaultValue = MAGCODE.Text;
Ligne 26 :         sourceMag.InsertParameters["MAGLIBELLE"].DefaultValue = MAGLIBELLE.Text;
Ligne 27 :         sourceMag.Insert();
Ligne 28 :         dgMagasin.DataBind();
Ligne 29 :     }
 
 
Fichier source : c:\Inetpub\wwwroot\Stock\gdpmagasin.aspx.cs    Ligne : 27 
 
Trace de la pile: 
 
 
[SqlException (0x80131904): Impossible d'insérer une valeur explicite dans la colonne identité de la table 'STKMAGASIN' quand IDENTITY_INSERT est défini à OFF.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +925466
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800118
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1005
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +149
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteDbCommand(DbCommand command, DataSourceOperation operation) +404
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert(IDictionary values) +447
   System.Web.UI.WebControls.SqlDataSource.Insert() +13
   gdpmagasin.btAjout_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\Stock\gdpmagasin.aspx.cs:27
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746