问题描述
- VS2010 C# 调用存储过程
-
C#具体代码调用以下存储过程USE [HWATT]
GO
/****** Object: StoredProcedure [dbo].[PRO_ADDCARD] Script Date: 02/16/2016 13:38:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GOALTER PROCEDURE [dbo].[PRO_ADDCARD]
@iismanual smallint,
@ircdtime datetime,
@idevid bigint,
@iemployeecode varchar(16),
@iemployeename varchar(250),
@iimagedata image,
@ircdtype smallint,
@ifrom_check smallint,
@ifaceidno varchar(5),
@iadminid bigint,
@iimagestatus smallint,
@isnewrcd bigint output
AS
begin
/* Procedure Text */
declare @iemployeeid bigint
declare @iimgid bigint
declare @icount bigint
declare @idevclass smallint
declare @istrcardid varchar(50)
declare @isqltext varchar(5000)
declare @iopid bigint
set @idevclass = 0
set @isnewrcd = 0
set @ircdtype = 0set @iemployeeid = (SELECT MAX(EMPLOYEEID) FROM KQZ_EMPLOYEE where employeecode = @iemployeecode and brchid = (select max(brchid) from kqz_employee where employeecode = @iemployeecode AND BRCHID != -3)) IF(@iemployeeid is null) BEGIN INSERT INTO kqz_employee(BrchID,BrchName,EmployeeCode,EmployeeName,gender,ModelNum,Privilege,DevTypeSTR,IsCheck,OnRule,OffRule,CanOvertime,HaveFesta,HavePwd) VALUES (1,'1',@iemployeecode,@iemployeename,2,0,0,'',1,0,0,1,1,0) set @iemployeeid = (select @@identity) END set @icount = (SELECT count(*) FROM KQZ_CARD T1 INNER JOIN KQZ_EMPLOYEE T2 ON T1.EMPLOYEEID = T2.EMPLOYEEID AND T2.EMPLOYEEID = @iemployeeid AND T2.EMPLOYEECODE = @iemployeecode AND CARDTIME = @ircdtime) if(@icount > 0) begin set @isnewrcd = -1 return @isnewrcd end if (@iimagedata IS NOT NULL) BEGIN insert into kqz_Img (ImgPhoto) values (@iimagedata) set @iimgid = (select @@identity) END ELSE BEGIN set @iimgid = 0 END INSERT INTO kqz_Card(EmployeeID,CardTime,CardTypeID,DevID,DevClass,ImgID,ImgStatus,IsValidate,ModifyUser,ModifyType,FaceIDNo) values (@iemployeeid,@ircdtime,@ircdtype,@idevid,@ifrom_check,@iimgid,@iimagestatus,0,0,0,@ifaceidno) set @isnewrcd = (select @@identity) IF(@iismanual = 1) BEGIN set @istrcardid = cast(@isnewrcd as varchar(30)) INSERT INTO KQZ_CARD_OP(OPTYPE,INSERTCONDITION,OPEMPLOYEE) VALUES(1,@istrcardid,@iadminid) set @iopid = (select @@identity) set @ISQLTEXT = N' INSERT INTO KQZ_CARD_OP_DETAILS(OPID,CARDID,EMPLOYEEID,CARDTIME,CARDTYPEID,DEVID,DEVCLASS,CVERIFY,IMGID,IMGSTATUS,ISVALIDATE, FACEIDNO,MODIFYUSER,MODIFYTYPE,MODIFYTIME) SELECT ' + cast(@iopid as varchar(30)) +',CARDID,EMPLOYEEID,CARDTIME,CARDTYPEID,DEVID,DEVCLASS,CVERIFY,IMGID,IMGSTATUS,ISVALIDATE, FACEIDNO,MODIFYUSER,MODIFYTYPE,MODIFYTIME FROM KQZ_CARD WHERE cardid = ' + cast(@istrcardid as varchar(30)) exec (@ISQLTEXT) end
return @isnewrcd
end
解决方案
把你的存储过程写到数据库中,然后参考下面的方法调用
http://blog.sina.com.cn/s/blog_4c79302301000ac0.html
解决方案三:
明显是你传入参数的没有匹配上,仔细检查一下
解决方案四:
存储过程的调用看下:http://blog.csdn.net/itblog/article/details/752869
解决方案五:
@iimagedata image,这个类型传入数据要是空,或就是错的