添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
i'm passing the other parameters to the stored procedure but how to get the
parameter which is of type output.
Stored Procedure:
/* ***** Object: StoredProcedure [dbo].[Sp_JobStep1] Script Date: 07/20/2014 22:40:33 ******/ SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON ALTER Proc [dbo].[Sp_JobStep1] @JobName nvarchar( 255 ) ,@JobCode nvarchar( 255 ) ,@StartDate date ,@EndDate date ,@JobID int output begin insert into Job JobName, JobCode, StartDate, EndDate select @JobName ,@JobCode ,@StartDate ,@EndDate select @JobID = @@IDENTITY from Job c# code:
SqlParameter[] Param = new SqlParameter[11]; Param[0] = new SqlParameter( " @JobName" , Jobname); Param[1] = new SqlParameter( " @JobCode" , JobCode); Param[2] = new SqlParameter( " @StartDate" , strDate); Param[3] = new SqlParameter( " @EndDate" , endDate); Param[4] = new SqlParameter( " @Client" , Client); Param[5] = new SqlParameter( " @JobDesc" , JobDesc); Param[6] = new SqlParameter( " @Rig" , rig); Param[7] = new SqlParameter( " @Well" , well); Param[8] = new SqlParameter( " @SectionID" , Section); Param[9] = new SqlParameter( " @hours" , hours); Param[10] = new SqlParameter( " @JobID" , SqlDbType.Int); Param[10].Direction = ParameterDirection.Output; if (Section > 0 ) DAL.Insertion( " Sp_JobStep1" , Param); // DataAccessLayer string JobID = Param[ " @JobID" ].Value.ToString(); // Error: Cannot implicitly convert string to int ["@JobID"] // how to deal with the sql parameter of type 'output' n its value.
plzzz suggest me.
Thanks string Jobname = txtjobname.Text; string JobCode = txtjobcode.Text; DateTime strDate = Convert.ToDateTime(txtsdate.Text); DateTime endDate = Convert.ToDateTime(txtedate.Text); string Client = txtclient.Text; string JobDesc = txtjobdescription.Text; int rig = Convert.ToInt32(ddlrig.SelectedValue); int well = Convert.ToInt32(ddlwell.SelectedValue); int Section = Convert.ToInt32(ddlSection.SelectedValue); string hours = txtehrs.Text; SqlParameter[] Param = new SqlParameter[11]; Param[0] = new SqlParameter( " @JobName" , Jobname); Param[1] = new SqlParameter( " @JobCode" , JobCode); Param[2] = new SqlParameter( " @StartDate" , strDate); Param[3] = new SqlParameter( " @EndDate" , endDate); Param[4] = new SqlParameter( " @Client" , Client); Param[5] = new SqlParameter( " @JobDesc" , JobDesc); Param[6] = new SqlParameter( " @Rig" , rig); Param[7] = new SqlParameter( " @Well" , well); Param[8] = new SqlParameter( " @SectionID" , Section); Param[9] = new SqlParameter( " @hours" , hours); Param[10] = new SqlParameter( " @JobID" , SqlDbType.Int); Param[10].Direction = ParameterDirection.Output; if (Section > 0 ) DAL.Insertion( " Sp_JobStep1" , Param); string JobID = Param[10].Value.ToString(); // Solved Response.Redirect( " JobStep2.aspx?JobID=" + JobID); catch (Exception) throw ;
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •