我用sqlserver存储过程编写了这段代码,我想单独运行到c代码中。问题是我不知道如何使用c#。这是存储过程的代码;
USE [SSFASys]
GO
/******Object: StoredProcedure [dbo].[userlogs] Script Date: 6/8/2018 2:19:30 PM******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[userlogs]
@id int,
@fullname varchar(150),
@activitydetails varchar(200),
@userform int,
@datelog datetime
as
declare @userid int
declare @activityid int
begin
SELECT @userid=id FROM endusers WHERE (fullname = @fullname) AND (id = @id)
select @activityid=id from enduseractivitydetials where activitydet=@activitydetails
If (@activityid is null)
Begin
INSERT INTO enduseractivitydetials VALUES (@activitydetails)
Select @activityid =SCOPE_IDENTITY()
end
if not exists(SELECT enduserLOGS.userid FROM enduserLOGS INNER JOIN enduseractivitydetials ON enduserLOGS.activitydetails = enduseractivitydetials.id INNER JOIN endusers ON enduserLOGS.userid = endusers.id
WHERE (endusers.fullname = @fullname) AND (enduserLOGS.date = @datelog) AND (endusers.id = @userid) AND (enduseractivitydetials.activitydet = @activitydetails))
begin
insert into enduserLOGS values (@userid,@userform,@activityid,@datelog)
end
end
我将我的数据库从sqlserver切换到mysql,以便我与其他软件开发人员一起采用,因为我正在与之斗争,我需要帮助。
谢谢。
1条答案
按热度按时间wlwcrazw1#
在一个块中可以同时执行多个语句;每条语句都必须以分号结尾
;
. 翻译时Stored Procedure
,输入参数不能在此块内声明;把每一个都当作SqlParameter
与SqlCommand
对象。对于
Stored Procedure
在您的问题中,这将如下所示。(因为我不能在这里执行,你可能要修改一些拼写错误;但你明白了。)