sql呼叫儲存過程

2021-04-14 16:49:58 字數 917 閱讀 3209

sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["easthhproductquoteconnectionstring"].tostring());

con.open();

sqlcommand cmd = new sqlcommand("pro_addlogreturnid", con);

cmd.commandtype = commandtype.storedprocedure;

cmd.parameters.add(new sqlparameter("@wl_id", sqldbtype.int));

cmd.parameters.add(new sqlparameter("@l_content", sqldbtype.varchar));

cmd.parameters.add(new sqlparameter("@l_redate", sqldbtype.varchar));

cmd.parameters.add(new sqlparameter("@id", sqldbtype.int, 4));

cmd.parameters["@wl_id"].value = userid;

cmd.parameters["@l_content"].value = logcontent;

cmd.parameters["@l_redate"].value = fortime;

cmd.parameters["@id"].direction = parameterdirection.output;

cmd.executenonquery();

int id = convert.toint32(cmd.parameters["@id"].value.tostring());

con.close(); 

SQL儲存過程呼叫標量值函式,儲存過程呼叫儲存過程

一 存 儲過程呼叫標量值函式 先建乙個標量值函式,如 create function dbo f num a nvarchar 50 returns nvarchar 50 asbegin declare m nvarchar 50 select m a aad return m end接下來 在儲...

SQL儲存過程游標呼叫儲存過程示例

if object id proc temp p is not null drop procedure proc temp go create procedure proc temp with recompile as select from student goexecute proc temp ...

MVC 呼叫SQL儲存過程

1 首先在web.config檔案中配置乙個與資料庫的連線connectionstrings 引數就不必說是什麼意思了吧 2 採用儲存過程mvc3的訪問資料庫的通用類 using system using system.collections.generic using system.linq us...