儲存過程的例子

2021-05-23 19:58:33 字數 2126 閱讀 5090

//帶引數儲存過程讀資料

public static void procinputreader()

sdr.close();

conn.close();

}//帶 引數、輸出 儲存過程讀資料 output

public static void procinputreader1()

//帶 引數、輸出 儲存過程讀資料 return 用法

public static void procinputreader2()

{sqlconnection conn = dbhelper.conn;

sqlcommand cmd = new sqlcommand("protest1", conn);

cmd.commandtype = commandtype.storedprocedure;

cmd.parameters.add("@percentage", sqldbtype.int, 0).value = 40;

sqlparameter param = new sqlparameter("@returnvalue", sqldbtype.int, 0);

param.direction = parameterdirection.returnvalue;

cmd.parameters.add(param);

cmd.executenonquery();

console.writeline(cmd.parameters["@returnvalue"].value);

conn.close();

//帶 引數、輸出 儲存過程讀資料 input 用法

public static void procinput()

{sqlconnection conn = dbhelper.conn;

sqlcommand cmd = new sqlcommand("inputtest", conn);

cmd.commandtype = commandtype.storedprocedure;

cmd.parameters.add("@percentage", sqldbtype.int, 0).value = 40;

cmd.parameters.add("@returnvalue", sqldbtype.int, 0);

cmd.parameters.add("@input", sqldbtype.int, 0);

cmd.parameters["@input"].direction = parameterdirection.input;

cmd.parameters["@returnvalue"].direction = parameterdirection.returnvalue;

cmd.parameters["@input"].value = 88;

cmd.executenonquery();

console.writeline(cmd.parameters["@returnvalue"].value);

conn.close();

//帶 引數、輸出 儲存過程讀資料 inputoutput 用法

public static void procinputoutput()

{sqlconnection conn = dbhelper.conn;

sqlcommand cmd = new sqlcommand("inputouttest", conn);

cmd.commandtype = commandtype.storedprocedure;

cmd.parameters.add("@percentage", sqldbtype.int, 0).value = 40;

cmd.parameters.add("@inputoutput", sqldbtype.int, 0);

cmd.parameters["@inputoutput"].direction = parameterdirection.inputoutput;

cmd.parameters["@inputoutput"].value = 66;

cmd.executenonquery();

console.writeline(cmd.parameters["@inputoutput"].value);

conn.close();

儲存過程例子

alter proc futurema updageorderdatasdistinguishresult asdeclare connectionstring nvarchar 256 declare server nvarchar 256 declare uid nvarchar 256 dec...

儲存過程例子

create table testtb id varchar2 30 name varchar2 30 insert into testtb values 1 21 insert into testtb values 2 22 insert into testtb values 3 23 inser...

mysql 儲存過程 例子 MySQL儲存過程例子

索引 index create index idx sname on student sname 4 alter table teacher add index idx tname tname drop index idx sname on student 檢視 view create view v...