C#调用存储过程出错
CREATE PROC test(@Categories varchar(500),@CategoriesType int,
@CategoriesLastType int,@CategoriesLastID varchar(50),@CategoriesURL varchar(500),
@GatherState int,@GatherDate DateTime,@CategoriesID varchar(50),@CategoriesName varchar(50),
@Type int,@LastType int)
AS
declare @Count int
declare @SQL varchar(1000)
begin
set @SQL= 'select ID from AmazonURL where Categories= '+@Categories+ ' and CategoriesType= '+@Type+ ' and CategoriesLastType= '+@LastType
@Count=exec(@SQL)
if(@Count> 0)
begin
set @SQL= 'nsert into AmazonURL(Categories,CategoriesType,CategoriesLastType,CategoriesLastID,CategoriesURL,
GatherState,GatherDate,CategoriesID,CategoriesName)
values( '+@Categories+ ', '+@CategoriesType+ ', '+@CategoriesLastType+ ', '+@CategoriesLastID+ ', '+@CategoriesURL+ ',
'+@GatherState+ ', '+@GatherDate+ ', '+@CategoriesID+ ', '+@CategoriesName+ ') '
exec(@SQL)
end
end
go
在@Count=exec(@SQL)地方出错,我想返回查询后是否有值,如果没有值就是Count <0则添加数据,请大家帮忙
------解决方案--------------------@Count=exec(@SQL)
这样不行嘀
用@str varchar(1000) output
------解决方案--------------------jf up 学习
------解决方案--------------------declare @SQL varchar(1000) output
@count= exec(@SQL)
------解决方案--------------------exec @count=(@SQL)