Nexto
Messages postés153Date d'inscriptiondimanche 2 octobre 2005StatutMembreDernière intervention27 juillet 2006
-
28 févr. 2006 à 11:40
Nexto
Messages postés153Date d'inscriptiondimanche 2 octobre 2005StatutMembreDernière intervention27 juillet 2006
-
1 mars 2006 à 11:55
Bonjour,
J'ai essayé de faire une page asp.net avec une simple page pour faire un ajout dans une base de donné mysql server. Pour cela j'ai utilisé une FormView et une SQLDataSource ou j'ai défini ma StoredProcédure "NewMembre" pour l'Insert.
Il m'a donc bien généré mon formulaire dans le formview. Seul problème il a mis aussi un label et un textbox pour l'id (qui est primarykey), jusque la sa allais (je devais donc entré une id manuellement dans le textbox comme les autre champs). Comme je voulais pas sa j'ai supprimé le label et textbox id dans le code. APrès, à l'exécution, quand je remplis les autre champs et que je valide il me fait une erreur pour l'id :
Cannot insert the value NULL into column 'id', table 'paris.dbo.membres'; column does not allow nulls. INSERT fails.
The statement has been terminated.
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.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'id', table 'paris.dbo.membres'; column does not allow nulls. INSERT fails.
The statement has been terminated.
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.
J'ai pourtant bien défini le DataKeyNames="id" dans mon FormView.
(pour info ma stored procédure est la suivante : )
ALTER PROCEDURE [mailto:dbo.NewMembre@id dbo.NewMembre
@id]
int
,@par
varchar(25)
,@date
nvarchar(15)
,@post
varchar(220)
AS
insert INTO [membres] ([id], [par], [date], [post])
values (@id, @par, @date, @post)
Nexto
Messages postés153Date d'inscriptiondimanche 2 octobre 2005StatutMembreDernière intervention27 juillet 20061 28 févr. 2006 à 15:58
J'ai déjà essayé mais même problème :
Server Error in '/WebSite3' Application.
<HR width="100%" color=silver SIZE=1>
Cannot insert the value NULL into column 'id', table 'paris.dbo.membres'; column does not allow nulls. INSERT fails.
The statement has been terminated.
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.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'id', table 'paris.dbo.membres'; column does not allow nulls. INSERT fails.
The statement has been terminated.
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.
cs_elpens
Messages postés260Date d'inscriptionvendredi 2 décembre 2005StatutMembreDernière intervention 3 novembre 2007 1 mars 2006 à 09:49
C'est normal de ne pas mettre de virgule au premier, car c'est une fonction. Mais c'est pour une raison de clarté que l'on met un return à chaque ligne...
ALTER PROCEDURE
dbo.NewMembre ( @par varchar(25), @date nvarchar(15), @post varchar(220) )
AS ...
Et le return permet de te retourner une valeur :
CREATE FUNCTION Square (@x int)
AS
BEGIN
RETURN @x * @x;
END