G
Guest
I'm using an ObjectDataSource with a stored procedure and am getting the
following error when trying to update (ExecuteNonQuery):
System.Data.SqlClient.SqlException: Procedure or Function 'UpdateRegistrant'
expects parameter '@EMail', which was not supplied.
The field value was null in the database and not changed in the FormView so
is null going back into the stored procedure. I'm stumped and would greatly
appreciate any suggestions.
TypeName code from RegistrantDB:
public void UpdateRegistrant(
RegistrantDetails reg
) {
SqlConnection con = new SqlConnection( connectionString );
SqlCommand cmd = new SqlCommand( "UpdateRegistrant", con );
cmd.CommandType = CommandType.StoredProcedure;
...
cmd.Parameters.Add( new SqlParameter( "@EMail", SqlDbType.NVarChar, 25 ) );
cmd.Parameters["@EMail"].Value = reg.EMail;
...
con.Open();
cmd.ExecuteNonQuery();
con.Close();
code from my DataObjectTypeName RegistrantDetails:
protected string eMail = String.Empty;
public string EMail
{
get {return eMail;}
set {eMail = value;}
}
My stored procedure UpdateRegistrant:
CREATE PROCEDURE [dbo].UpdateRegistrant
@RegistrantId int,
@FirstName nvarchar(25),
@MI nvarchar(3),
@LastName nvarchar(25),
@EMail nvarchar(25),
...
AS
UPDATE [dbo].[Registrants] SET
[FirstName] = @FirstName,
[MI] = @MI,
[LastName] = @LastName,
(e-mail address removed)
following error when trying to update (ExecuteNonQuery):
System.Data.SqlClient.SqlException: Procedure or Function 'UpdateRegistrant'
expects parameter '@EMail', which was not supplied.
The field value was null in the database and not changed in the FormView so
is null going back into the stored procedure. I'm stumped and would greatly
appreciate any suggestions.
TypeName code from RegistrantDB:
public void UpdateRegistrant(
RegistrantDetails reg
) {
SqlConnection con = new SqlConnection( connectionString );
SqlCommand cmd = new SqlCommand( "UpdateRegistrant", con );
cmd.CommandType = CommandType.StoredProcedure;
...
cmd.Parameters.Add( new SqlParameter( "@EMail", SqlDbType.NVarChar, 25 ) );
cmd.Parameters["@EMail"].Value = reg.EMail;
...
con.Open();
cmd.ExecuteNonQuery();
con.Close();
code from my DataObjectTypeName RegistrantDetails:
protected string eMail = String.Empty;
public string EMail
{
get {return eMail;}
set {eMail = value;}
}
My stored procedure UpdateRegistrant:
CREATE PROCEDURE [dbo].UpdateRegistrant
@RegistrantId int,
@FirstName nvarchar(25),
@MI nvarchar(3),
@LastName nvarchar(25),
@EMail nvarchar(25),
...
AS
UPDATE [dbo].[Registrants] SET
[FirstName] = @FirstName,
[MI] = @MI,
[LastName] = @LastName,
(e-mail address removed)