Home > Net >  SQL server stored procedure
SQL server stored procedure

Time:09-16

Want to do a simple mall, according to a hole a lot of broken book, too many questions, do this step can't solve, ask next everybody
Public DataTable ExactOrderSearch (int IntOrderID, int IntNF, string strName, int IntIsConfirm, int IntIsSend, int IntIsEnd)
{
//execute the stored procedure call GetCommandProc DBClass class method, return to Sqlcommand object
SqlCommand myCmd=dbObj. GetCommandProc (" Proc_SearchOI ");
//add parameters - order number
SqlParameter orderID=new SqlParameter (" @ orderID ", SqlDbType. Int, 4);
OrderID Value=https://bbs.csdn.net/topics/IntOrderID;
MyCmd. The Parameters. The Add (orderID);
//add parameters - logo whether to fill in the consignee name
SqlParameter nf=new SqlParameter (" @ nf ", SqlDbType. Int, 4);
Nf. Value=https://bbs.csdn.net/topics/IntNF;
MyCmd. The Parameters. The Add (nf);
//add parameters - the consignee name
SqlParameter name=new SqlParameter (" @ the name ", SqlDbType VarChar, 50);
The name Value=https://bbs.csdn.net/topics/strName;
MyCmd. The Parameters. The Add (name);
//add parameters - whether confirm
SqlParameter confirm=new SqlParameter (" @ IsConfirm ", SqlDbType. Int, 4);
Confirm the Value=https://bbs.csdn.net/topics/IntIsConfirm;
MyCmd. The Parameters. The Add (confirm); ;
//add parameters, whether the delivery
SqlParameter send=new SqlParameter (" @ IsSend ", SqlDbType. Int, 4);
Send. Value=https://bbs.csdn.net/topics/IntIsSend;
MyCmd. The Parameters. The Add (send);
//add parameters - whether archive
SqlParameter end=new SqlParameter (" @ IsEnd ", SqlDbType. Int, 4);
End Value=https://bbs.csdn.net/topics/IntIsEnd;
MyCmd. The Parameters. The Add (end);
//call DBClass GetDataSet method of filling the SQL query, return a collection of data sets of tables
The DataTable dsTable=dbObj. GetDataSet (myCmd, "tbOI");
Return dsTable;
}
The stored procedure how to write things, need not to need the if exsits what of, can't see because no NF the column in the table, and the consignee is not
Named the Name directly, in the table is ReceiverName, I want correct according to the table or in accordance with the code to not change?

CodePudding user response:

There didn't say the Name or NF such columns, just have such parameters,


Maybe the code is written ReceiverName=@ Name this
?
You'll have to see what I look like a stored procedure code

CodePudding user response:

Empty several parameters, write not to come out, don't know the logic

CodePudding user response:

long time no see

CodePudding user response:

These are all parameters, not the column name
Don't have to change
You run directly, see if there is any error

CodePudding user response:

references to elder brother reply all points: 3/f
long time no see

Hey, don't you are

CodePudding user response:

Hello World, 1/f, reference response:
there didn't say the Name or NF such columns, just have such parameters,


Maybe the code is written ReceiverName=@ Name this
?
You'll have to see what I look like a stored procedure code of

Do not understand the stored procedure, since references were not so @ column names behind with the data types are with the corresponding data column is

CodePudding user response:

@ var is a variable name, not the column name, can be the same or different

CodePudding user response:

Hello World, reference 7 floor response:
@ var is a variable name, not the column name, can be the same or different

The SqlParameter nf=new SqlParameter (" @ nf ", SqlDbType. Int, 4); After NF is variable, in the definition to a web page? I didn't do it behind I don't know yet

CodePudding user response:

This should be a query, you go looking for a return to the process of data collection of the demo, then change your own good, very simple, written before, forget now

CodePudding user response:


The
reference o f LiangLiang wood on the fire response:
so SqlParameter nf=new SqlParameter (" @ nf ", SqlDbType. Int, 4); After NF is variable, in the definition to a web page? I didn't do it later also don't know


Here have given parameter value, the function returns the DataTable, no longer need to variable reprocessing,
Do it again to know
//add parameters - logo whether to fill in the consignee name 
SqlParameter nf=new SqlParameter (" @ nf ", SqlDbType. Int, 4);
Nf. Value=https://bbs.csdn.net/topics/IntNF;
MyCmd. The Parameters. The Add (nf);


CodePudding user response:

Your post code, can know the name of a stored procedure and several parameters, should be only input parameters, output parameters, roughly as follows:
 IF OBJECT_ID (' Proc_SearchOI) IS NOT NULL 
DROP the PROC Proc_SearchOI
GO
The CREATE PROC Proc_SearchOI
(
@ OrderID INT,
@ NF INT,
@ Name VARCHAR (50),
@ IsConfirm INT,
@ IsSend INT,
@ IsEnd INT
)
AS
The BEGIN
- specific code stored procedure
END
GO


Specific stored procedures, or according to you here to implement the business logic to write,
  • Related