Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÔÚc#ÖеÄÈ¡µÃsql´æ´¢¹ý³ÌµÄoutput²ÎÊý

һֱûÓÐÕÒµ½Ò»Öֺõķ½·¨À´ÒýÓÃÓзµ»ØÖµµÄ´æ´¢¹ý³ÌµÄ·½·¨£¬Ê¹ÎÒÔÚÌí¼ÓÊý¾ÝÖÐ×ßÁ˲»ÉÙµÄÍä·£¬×î½ü£¬ÔÚ²éÔÄÁË´óÁ¿µÄ×ÊÁÏÖ®ºó£¬ÖÕÓÚÔÚ΢ÈíµÄÒ»¸öʵÀýÖÐÕÒµ½ÁËÒ»ÖÖÁ¼ºÃµÄ·½·¨¡£
Ê×ÏȱàдºÃÒ»Óзµ»ØÖµµÄ´æ´¢¹ý³Ì
create procedure proc_name
   @para1 nchar(20),    --ÊäÈë²ÎÊý
   @para2 int = null out¡¡--Êä³ö²ÎÊý£¬¹©³ÌÐòʹÓÃ
as
   set nocount on
   if ( not exists (select * from employee where em_name=@para1))
   begin
       insert into employee(name) values(@para1)  
       select @para2=@@identity      --·µ»ØÌí¼Ó¼Ç¼µÄID
       return 1                                --·µ»ØÊÇ·ñ³É¹¦Ìí¼ÓÊý¾Ý
   end
   else
      return 0                               --·µ»Øʧ°Ü
go
È»ºóÊǵ÷Óô洢¹ý³ÌµÄ·½·¨
sqlcommand command;
command = new sqlcommand(proc_name,new sqlconnection(connectionstr));
command.paraments.add("@para1"),"name1");  //ÊäÈë²ÎÊý£¬Ö°Ô±ÐÕÃû
command.paraments.add(new sqlparament("@para2",   //Éú³ÉÒ»Êä³ö²ÎÊý
SqlDbType.Int;¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//²ÎÊýÊý¾ÝÀàÐÍ
ParamenterDirection.OutPut,¡¡¡¡¡¡¡¡¡¡¡¡//ÊäÈëÊä³öÀàÐÍ
0,
0,
string.Emplty,
DataRowVerstion.Default,
null)¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//²ÎÊýÖµ£¬ÊäÈë²ÎÊýʱÐèÌṩ
);
command.commandtype=commandtype.StoredProcedure;
command.connection.open();
command.executenonQuery();
int pkid=(int)command.Parameters["@para2"].value;  //µÃµ½Êä³ö²ÎÊýµÄÖµ
command.connection.close();
´Ë´¦ÊÇÒýÓÃÊä³ö²ÎÊý£¬Èç¹ûÒªÒýÓ÷µ»ØÖµ£¨ÊÇ·ñ³É¹¦Ìí¼ÓÊý¾Ý£©ÔòÖ»Ðè°ÑParamenterDirec


Ïà¹ØÎĵµ£º

SQL 2005 ´´½¨Ô¼Êø

²Î¼û¡¶SQL Sever 2005 Êý¾Ý¿â»ù´¡¼°Ó¦Óü¼Êõ½Ì³ÌÓëʵѵ¡· ÖÜÆæ
 
SQL ServerÖÐÓÐÎåÖÖÔ¼ÊøÀàÐÍ£¬·Ö±ðÊÇCHECKÔ¼Êø¡¢DEFAULTÔ¼Êø¡¢PRIMARY KEYÔ¼Êø¡¢FOREIGN KEYÔ¼ÊøºÍUNIQUEÔ¼Êø¡£
 
1.       CHECKÔ¼Êø£º
CHECKÔ¼ÊøÓÃÓÚÏÞÖÆÊäÈëÒ»Áлò¶àÁеÄÖµµÄ·¶Î§£¬Í¨¹ýÂß¼­±í´ïʽÀ´ÅжÏÊý¾ ......

PL/SQL ÖÐÎÄÂÒÂë½â¾ö·½°¸

1. ʹÓõÄÊÇ·þÎñÆ÷Éϵģ¬²»ÊDZ¾»úµÄOracle£¬°´ÏÂÃæ×ö¾Í¿ÉÒÔÁË£º
    ÉèÖû·¾³±äÁ¿:NLS_LANG£¬¾ßÌåÖµÓÃÏÂÃæ²éѯµÄÖµ:
SELECT 'AMERICAN_AMERICA.' || PROPERTY_VALUE
from DATABASE_PROPERTIES
WHERE PROPERTY_NAME = 'NLS_CHARACTERSET';
2. Èç¹ûÊDZ¾»úµÄOracle¾ÍÐèÒªÔÚOracleµÄ°²×°Ä¿Â¼ÏÂÃæ¸ÄÉèÖãº
......

sql server Ë÷ÒýÈëÃÅ

    ×î½ü×öÁËÒ»ÍøÕ¾£¬µ«ÊÇÔÚÍâÃæ·ÃÎÊÌ«Âý¡£±¾ÏëÕÒÏÂÔ­Òò¡£¿´¿´ÊdzÌÐòÔ­Òò»¹ÊÇÊý¾Ý¿âÔ­Òò¡£ÔÚÍøÉϹä¹ä¡£¿´ÁËÒ»ÏÂÊý¾Ý¿âË÷Òý¡£ÏÖÔÚ×ܽáһϡ£·½±ãÏ´β鿴¡£±¾ÎıȽϻù´¡ÊÇÈëÃż¶±ðµÄ¡£
     Ê×ÏÈ£¬Ê²Ã´ÊÇË÷Òý£¿´ÓBookOnlineÉÏsearchÁËһϣº    
  &nbs ......

sql:´æ´¢¹ý³Ì£¬ÊÂÎñ£¬out²ÎÊý

CREATE proc [dbo].[proc_DeleteTemplet] (@templeId varchar(15),@errorMessage varchar(50) output)
as
begin
  declare @error int
  set @error =0
  begin tran
  delete from tc_templet_Head where fBillNo=@templeId
  set @error=@error+@@error
  delete from tc_templet_ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ