sql 함수 :
함수 tcupom (@cupom int)을 작성하십시오. 플로트를 반환합니다 ~처럼 시작하다 @TCU 플로트를 선언; alteraca2에서 @tcu = sum (총)을 선택하십시오. 여기서 pedido = @cupom if (@tcu is null) @tcu = 0을 설정합니다. @TCU를 반환합니다. end
c# 코드 :
create function TCupom (@cupom int) returns float as begin declare @Tcu float; select @Tcu = sum (total) from alteraca2 where pedido = @cupom if (@tcu is null) set @tcu = 0; return @tcu; end
원본 코드의 오류 :
원본 C# 코드는 두 가지 실수를 저지른다. UDFS. 컵 놈) { 플로트 상세; sqldataadapter da2 = 새로운 sqldataadapter (); if (conex1.state == ConnectionState.Closed) { conex1.open (); } sqlcommand totalf = new sqlcommand ( "select dbo.tcupom (@code)", conex1); sqlparameter code1 = 새로운 sqlparameter ( "@code", sqldbtype.int); Code1.Value = Cupom; saida = totalf.executescalar (); 반환 Saida; } 설명 :
부인 성명: 제공된 모든 리소스는 부분적으로 인터넷에서 가져온 것입니다. 귀하의 저작권이나 기타 권리 및 이익이 침해된 경우 자세한 이유를 설명하고 저작권 또는 권리 및 이익에 대한 증거를 제공한 후 이메일([email protected])로 보내주십시오. 최대한 빨리 처리해 드리겠습니다.
Copyright© 2022 湘ICP备2022001581号-3