2 tong275056839 tong275056839 于 2016.02.16 13:50 提问

VS2010 C# 调用存储过程 2C

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
GO

ALTER 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 = 0

    set @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

5个回答

bdmh
bdmh   Ds   Rxr 2016.02.16 13:57

把你的存储过程写到数据库中,然后参考下面的方法调用
http://blog.sina.com.cn/s/blog_4c79302301000ac0.html

tong275056839
tong275056839   2016.02.16 14:52

图片说明就是出现这样的问题

YUELIANG412724
YUELIANG412724   2016.02.16 16:23

明显是你传入参数的没有匹配上,仔细检查一下

Mr_dsw
Mr_dsw   Ds   Rxr 2016.02.16 22:16
tong275056839
tong275056839   2016.02.17 15:20

@iimagedata image,这个类型传入数据要是空,或就是错的

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!