I tried with ExecuteReader, ExecuteNonQuery but still i was getting the -1 or 0 for the Output paramter of SP
Anyways,
I found the following way to get the value:
From My SP I have written Select statement to get the newly created row's Unique ID (PK)
SELECT InformationIconFileID = SCOPE_IDENTITY ()
FROM [dbo].[TB_CON_InformationIconFile] iif
WHERE iif.[PortalID] = @PortalID
AND iif.[TabModuleID] = @TabModuleIDAND iif.[ConfiguratorColumnID] = @ConfiguratorColumnID
AND iif.[FileName] = @FileName
this returns one recordset from SP which I am fetching using SqlDataReader. And returns the single column and single row record. Means only one cell
And from SqlDataProvider I have written this simple code:
public override int UploadInfoIconFile(int PortalId, int TabModuleId, int ConfiguratorColumnId, string FileName, string Extension, int Size, string ContentType, byte[] Content)
{
int _returnFileId = 0;
SqlParameter FileId = new SqlParameter("@FileID", SqlDbType.Int);
FileId.Direction = ParameterDirection.Output;
SqlDataReader myReader = SqlHelper.ExecuteReader(ConnectionStringConfig, "PR_CON_InformationIconFileSave", new object[] { PortalId, TabModuleId, ConfiguratorColumnId, FileName, Extension, Size, ContentType, Content, FileId });
while (myReader.Read())
{
_returnFileId = Convert.ToInt32(myReader.GetValue(0));
}
return _returnFileId;
}
That's it :)
And now my code is working fine.
Anyways,
If you feel this wrong or not very optimized please let me know.
Thanks all for your replies,
Deepak Khopade