-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: pradeep145
Message 1 in Discussion

hi all i have a C# DLL .In that DLL one of the function have 3 input variables and 1 
out put. i used to call a stored procedure in That DLL function.pls tell me how can i 
retrieve the output parameter value in my DLL function.how to pass the out put 
variable in the soored procedure. my DLL function is    
public int AddSchedule(string strSchedule_Name,string strStartDate,string 
strEndDate,out int nSchedule_Id, out string strErrorDescription) 
{ 
DataSet ds = new DataSet();  
strErrorDescription="" ; 
try 
{ 
 
// Establish connection if it is closed 
if (conStatus == false) 
{ 
EstbConnection(); 
} 
string sqlQuery = "Execute DBO.udsp_Add_Schedule 
@strSchedule_Name,@strStartDate,@strEndDate,@nSchedule_Id"; 
SqlDataAdapter daLMS = new SqlDataAdapter(sqlQuery ,conEL);  
daLMS.SelectCommand.Parameters.Add( new 
SqlParameter("@strSchedule_Name",SqlDbType.VarChar)); 
daLMS.SelectCommand.Parameters["@strSchedule_Name"].Value = strSchedule_Name; 
daLMS.SelectCommand.Parameters.Add( new 
SqlParameter("@strStartDate",SqlDbType.VarChar)); 
daLMS.SelectCommand.Parameters["@strStartDate"].Value = strStartDate; 
daLMS.SelectCommand.Parameters.Add( new 
SqlParameter("@strEndDate",SqlDbType.VarChar)); 
daLMS.SelectCommand.Parameters["@strEndDate"].Value = strEndDate; 
daLMS.SelectCommand.Parameters.Add( new 
SqlParameter("@nSchedule_Id",SqlDbType.VarChar)); 
daLMS.SelectCommand.Parameters["@nSchedule_Id"].Value = nSchedule_Id; 
daLMS.Fill(ds); 
 
} 
catch(Exception Err) 
{ 
strErrorDescription = Err.Message; 
} 
return nSchedule_Id; 
} 
  
but it is giving some error like schedule_id must be assigned before control leaves 
the current method. 
  
my stored procedure code is like this 
CREATE PROCEDURE DBO.udsp_Add_Schedule 
 @strSchedule_Name VARCHAR(50), 
 @StartDate DATETIME,
 @EndDate DATETIME,
              @nItemId INT  OUTPUT              
AS
BEGIN
 DECLARE  @nCheck  INTEGER
 SET  @nCheck = ( SELECT COUNT(*)  FROM  tblSchedule  WHERE  Schedule_Name  =  
@strSchedule_Name )
 IF (  @nCheck = 1 )
  RAISERROR ( 'A Schedule with this Name already Exists' , 11, -1 )
 ELSE
 INSERT INTO  tblSchedule  VALUES  ( @strSchedule_Name ,  @StartDate ,@EndDate )
             SET @nItemId  =  (SELECT MAX (Schedule_Id) FROM  tblSchedule)
END
GO


-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to