问题描述
DbCommandcomm=db.GetStoredProcCommand(usp_User_FindByNameAndPassword);db.AddInParameter(comm,"v_Name",DbType.String,name);db.AddInParameter(comm,"v_Password",DbType.String,password);db.AddOutParameter(comm,"cur_out",DbType.Object,0);DataSetds=db.ExecuteDataSet(comm);
CREATEORREPLACEPROCEDUREusp_User_FindByNameAndPassword--=============================================--Author:<Author,,Name>--Createdate:<CreateDate,,>--Description:<Description,,>--=============================================(v_NameINNVARCHAR2DEFAULTNULL,v_PasswordINNVARCHAR2DEFAULTNULL,cur_outINOUTSYS_REFCURSOR)ASBEGIN--SETNOCOUNTONaddedtopreventextraresultsetsfrom--interferingwithSELECTstatements.--InsertstatementsforprocedurehereOPENcur_outFORSELECT*FROMUSERSWHERENAME=v_NameANDPASSWORD=v_Password;END;
DataSetds=db.ExecuteDataSet(comm);出错了。“参数绑定无效参数名:cur_out”用的是ODP.NET11gfor.netframework4
解决方案
解决方案二:
先在查询分析器里看看你的存储过程有错没啊
解决方案三:
用游标返回
解决方案四:
DbCommandcomm=db.GetStoredProcCommand(usp_User_FindByNameAndPassword);db.AddInParameter(comm,"v_Name",DbType.String,name);db.AddInParameter(comm,"v_Password",DbType.String,password);/*Whenwecallthestoredprocedurewhichreturnsasinglerefcursor,DAABautomaticallycreatesaparameteroftypecursor.Thenameoftheautomaticallycreatedparameteriscur_OUT.Here,onepointshouldbekeptinmindthatthenameoftherefcursorinyourstoredproceduremustbecur_OUT.So,incaseofstoredprocedurewhichreturnssinglerefcursor,youneednotpassrefcursorasparametertoDbCommandobject.*///db.AddOutParameter(comm,"cur_out",DbType.Object,0);DataSetds=db.ExecuteDataSet(comm);
解决方案五:
也就是说,你不用显式的声明游标参数,DAAB会自动创建。
解决方案六:
详情,请参照:http://blog.sina.com.cn/s/blog_3f2ef1180100xci9.html