hi this is stored procedure:
DELIMITER $$
CREATE DEFINER=`gps`@`%` PROCEDURE `SpAssetLost`(in HistoryID int,in AssetLostID int,in HistoryName varchar(250),in Remarks varchar(250),
in UserID int,in InMode varchar(200))
Begin
if inmode= 'INSERT' then
insert into trnassetlost(HistoryID,HistoryName,Remarks,UserID)Values(HistoryID,HistoryName,Remarks,UserID);
end if;
if inmode='UPDATE' then
update trnassetlost set HistoryID=HistoryID,HistoryName=HistoryName,Remarks=Remarks,UserID=UserID where
AssetLostID=AssetLostID;
end if;
if inmode='DELETE' then
update trnassetlost set IsActive='FALSE' where AssetLostID=AssetLostID;
end if;
if inmode='SELECT' then
select * from trnassetlost;
end if;
end
I was wrote select function in my class file using c#:
public Access objAccess = new Access();
public DataSet SELECT(BALAssetLost ObjAl)
{
param = new MySqlParameter[1];
param[0] = new MySqlParameter("@inmode", "SELECT");
DataSet ds = objAccess.GetDataSet(param, "SpAssetLost");
return ds;
}
Access.cs:
public DataSet GetDataSet(MySqlParameter[] param, string procedure)
{
try
{
establishConnection();
try
{
if (con.State == ConnectionState.Open)
{
con.Close();
}
con.Open();
MySqlCommand cmd = new MySqlCommand(procedure, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddRange(param);
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
catch (Exception ex)
{
throw ex;
}
}
catch (Exception ex)
{
throw ex;
}
}
now i got error "Parameter 'HistoryID' not found in the collection".so i want to set null in unwanted variables.how can i declare null while creating stored procedure in mysql workbench.
PLEASE ANYBODY HELP ME.
Please anybody help me.