hi,
i am having trouble with this problem from last week.
The problem gets more trickier bcoz when I try to insert record it shows this error"Procedure or Function 'Nav_Bulletins_Insert' expects parameter '@Bulletin', which was not supplied." but
in DB the value is stored!
PLease solve this asap.
Stored Procedure looks like this:-
A
LTER procedure [dbo].[Nav_Bulletins_Insert]
(
@Bulletin nvarchar(500),
@Url nvarchar(200),
@IsActive bit
)
as
declare @DisplayId int
declare @Count int
declare @PostedDate nvarchar(100)
select @Count=count(*) from Nav_Bulletins
set @DisplayId=@Count+1
set @PostedDate = getdate()
insert into Nav_Bulletins(Bulletin,Url,IsActive,PostedDate,Dis playId)
values(@Bulletin, @Url, @IsActive, @PostedDate, @DisplayId)
C# code:-
public void Nav_InsertBulletins()
{
DBManager.ExecuteNonQuery("Nav_Bulletins_Insert", _str_Bulletin, _str_Url, _Is_Active);
}
DB MANAGER.cs:
public static int ExecuteNonQuery(string spName, params object[] parameterValues)
{
SqlParameter[] commandParameters = null;
if (parameterValues != null & parameterValues.Length > 0)
{
commandParameters = GetParametersSetFromSp(spName);
AssignParameterValues(commandParameters, parameterValues);
return ExecuteNonQuery(CommandType.StoredProcedure, spName, commandParameters);
}
else
{
return ExecuteNonQuery(CommandType.StoredProcedure, spName);
}
}
public static int ExecuteNonQuery(CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
SqlConnection cn = new SqlConnection(_connectionString);
try
{
cn.Open();
return ExecuteNonQuery(cn, commandType, commandText, commandParameters);
}
finally
{
cn.Close();
cn.Dispose();
}
}
public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
int retval = 0;
PrepareCommand(cmd, connection, commandType, commandText, commandParameters);
retval = cmd.ExecuteNonQuery(); error points here
cmd.Parameters.Clear();
return retval;
}