G
Guest
I get the error 'Procedure 'spBO_HeadlineCreate' expects parameter
'@imageid', which was not supplied' when i call the procedure with the
@imageid=null, but id the @imageid as a diff. value no error occurs.
Here's the code and the storedproc...
-- code
SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection
ConfigurationSettings.AppSettings["cnStrDBAdmin"]); // Create connection.
SqlCommand sqlUpdProg=new SqlCommand ();
sqlUpdProg.CommandType=CommandType.StoredProcedure;
sqlUpdProg.CommandText="spBO_ProgramSave";
sqlUpdProg.Connection=sqlConnection ;
//Handle the parameters
sqlUpdProg.Parameters.Add("@title", SqlDbType.NVarChar);
sqlUpdProg.Parameters.Add("@imageid", SqlDbType.BigInt);
sqlUpdProg.Parameters.Add("@date", SqlDbType.DateTime);
sqlUpdProg.Parameters.Add("@text", SqlDbType.NText );
sqlUpdProg.Parameters["@title"].Value = _title;
sqlUpdProg.Parameters["@date"].Value = _date;
sqlUpdProg.Parameters["@text"].Value = _body;
if (_imageid!=-1)
sqlUpdProg.Parameters["@imageid"].Value = _imageid;
else
sqlUpdProg.Parameters["@imageid"].Value =null; //error occur
try
{
sqlConnection.Open();
int statusNews = sqlUpdProg.ExecuteNonQuery();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("ERROR: " + ex.ToString());
throw(ex);
}
finally
{
sqlConnection.Close(); //Close the Connection.
}
--code
--storedproc
CREATE PROCEDURE dbo.spBO_ProgramSave
@date smalldatetime,
@title nvarchar(100),
@imageid bigint,
@text ntext
AS
SET NOCOUNT ON
UPDATE dbo.t_programs SET
[date] = @date,
title = @title,
imageid = @imageid,
[text] = @text
GO
--storedproc
i would appreciate any help, thanks a lot
'@imageid', which was not supplied' when i call the procedure with the
@imageid=null, but id the @imageid as a diff. value no error occurs.
Here's the code and the storedproc...
-- code
SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection
ConfigurationSettings.AppSettings["cnStrDBAdmin"]); // Create connection.
SqlCommand sqlUpdProg=new SqlCommand ();
sqlUpdProg.CommandType=CommandType.StoredProcedure;
sqlUpdProg.CommandText="spBO_ProgramSave";
sqlUpdProg.Connection=sqlConnection ;
//Handle the parameters
sqlUpdProg.Parameters.Add("@title", SqlDbType.NVarChar);
sqlUpdProg.Parameters.Add("@imageid", SqlDbType.BigInt);
sqlUpdProg.Parameters.Add("@date", SqlDbType.DateTime);
sqlUpdProg.Parameters.Add("@text", SqlDbType.NText );
sqlUpdProg.Parameters["@title"].Value = _title;
sqlUpdProg.Parameters["@date"].Value = _date;
sqlUpdProg.Parameters["@text"].Value = _body;
if (_imageid!=-1)
sqlUpdProg.Parameters["@imageid"].Value = _imageid;
else
sqlUpdProg.Parameters["@imageid"].Value =null; //error occur
try
{
sqlConnection.Open();
int statusNews = sqlUpdProg.ExecuteNonQuery();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("ERROR: " + ex.ToString());
throw(ex);
}
finally
{
sqlConnection.Close(); //Close the Connection.
}
--code
--storedproc
CREATE PROCEDURE dbo.spBO_ProgramSave
@date smalldatetime,
@title nvarchar(100),
@imageid bigint,
@text ntext
AS
SET NOCOUNT ON
UPDATE dbo.t_programs SET
[date] = @date,
title = @title,
imageid = @imageid,
[text] = @text
GO
--storedproc
i would appreciate any help, thanks a lot