01.
02.
public
int
GetTotal(
string
status)
03.
{
04.
int
totalResult = 0;
05.
06.
using
(MySqlConnection conn =
new
MySqlConnection(
"connection string ต่อฐานข้อมูลนะครับ"
))
07.
08.
using
(MySqlCommand cmd =
new
MySqlCommand(
"CountOrderByStatus"
, conn))
09.
{
10.
11.
cmd.CommandType = CommandType.StoredProcedure;
12.
13.
14.
15.
cmd.Parameters.AddWithValue(
"?orderStatus"
, status);
16.
cmd.Parameters[
"?orderStatus"
].Direction = ParameterDirection.Input;
17.
18.
19.
20.
cmd.Parameters.Add(
new
MySqlParameter(
"?total"
, MySqlDbType.Int32));
21.
cmd.Parameters[
"?total"
].Direction = ParameterDirection.Output;
22.
23.
24.
conn.Open();
25.
26.
27.
cmd.ExecuteNonQuery();
28.
29.
30.
conn.Close();
31.
32.
33.
totalResult = (
int
)cmd.Parameters[
"?total"
].Value;
34.
}
35.
36.
return
totalResult;
37.
}