儲存過程:
create procedure customer_select
@country nvarchar(15)
asselect customerid,companyname,contactname from customers where country=@country
go.aspx:
.cs:
protected void dropdownlist1_selectedindexchanged(object sender, eventargs e)
{//建立連線字串
string connstring = "data source=.;initial catalog=northwind;user id=sa;password=sa";
//建立操作物件
sqldataadapter adp = new sqldataadapter();
sqlcommand cmd = new sqlcommand();
cmd.connection = new sqlconnection( connstring);
datatable dt = new datatable();
//制定要呼叫的儲存過程名稱"customer_select";
//指定sqlcommand物件的命令型別為storedprocedure 列舉型別
cmd.commandtext = "customer_select";
cmd.commandtype = commandtype.storedprocedure;
//指定 sqlparameter物件,指定引數名稱,資料型別 長度以及引數
sqlparameter para = new sqlparameter("@country",sqldbtype.nvarchar,15);
para.value = dropdownlist1.selectedvalue;
cmd.parameters.add(para);
//關聯sqldataadapter和sqlcommand
adp.selectcommand = cmd;
adp.fill(dt);
gridview1.datasource = dt;
gridview1.databind();
儲存過程帶in引數
set ansi nulls on set quoted identifier on goalter procedure dbo testlist userid nvarchar 4000 asdeclare search array nvarchar 100 begin set search ar...
oracle儲存過程 帶引數的儲存過程
帶引數的儲存過程 舉例 為指定的員工漲100元的工資,列印漲前和漲後的工資 如果帶參,需要指定是輸入引數還是輸出引數 create orreplace procedure raisesalary eno in number as 定義乙個變數儲存漲前的薪水,引用emp中sal的型別作為psal的型別...
帶引數的儲存過程sp executesql
示例 exec sp executesql n select role.userid from role where role.userid paramuserid n paramuserid nvarchar 4000 paramuserid n 123457 說明 sp executesql 執...