Thanks you all!
I have solved myself that. But it have a little rule in creating sql procedure and call the return function. And then it use oledbconnection and oledbcommand instead sqlconnection and sqlcommand. Because sqlcon or com is you will be know exactly the para of proc1 or proc2 like that @ID or @CardID. But oledb not need. That's my thinking because I don't know about c# as well. Now my level is just as beginner. My code is as follow.
Alter Procedure Proc1(@a int, @b int, @c int, @d int output, @e int output)
begin
......
end
Alter Procedure Proc2(@f int, @g int, @h int, @i int, @j int output, @k int output, @l int output)
begin
......
end
When procedure create, the rule is value para and output para are separate as about. Just not like as below...
Alter Procedure Proc2(@f int, @g int output, @h int, @i int, @j int output, @k int output, @l int)
begin
......
end
string Separate="Separator";
private static Object[] Get_SPParams;
Get_SPParams = ReturnProcedure("Proc1", vID, vName, vPhone, Separate, d, e);
d = Get_SPParams[4].ToString();
e = Get_SPParams[5].ToString();
Get_SPParams = ReturnProcedure("Proc2", f, g, h, i, Separate, j, k, l);
j = Get_SPParams[5].ToString();
k = Get_SPParams[6].ToString();
l = Get_SPParams[7].ToString();
public static Object[] ReturnProcedure(string SPName, params Object[] SPParams)
{
bool found;
string GetStr="";
found = false;
try
{
OleDBCmd = new OleDbCommand();
OleDBCmd.Connection = OleDBConn;
OleDBConn.Open();
OleDBCmd.CommandType = CommandType.StoredProcedure;
OleDBCmd.CommandText = SPName.Trim();
for (int i = 0; i < SPParams.Length; i++)
{
GetStr = SPParams[i].ToString();
if (GetStr == "Separate")
{
found = true;
i++;
}
if (found == false)
{
OleDBCmd.Parameters.Add(new OleDbParameter());
OleDBCmd.Parameters[i].Value = SPParams[i];
}
else
{
OleDBCmd.Parameters.Add(new OleDbParameter() {Direction = ParameterDirection.Output});
OleDBCmd.Parameters[i-1].Value = SPParams[i];
}
}
OleDBCmd.ExecuteNonQuery();
for (int i = 0; i < SPParams.Length - 1; i++)
{
if (((OleDBCmd.Parameters[i].Direction == ParameterDirection.InputOutput) || (OleDBCmd.Parameters[i].Direction == ParameterDirection.Output)) && (OleDBCmd.Parameters[i].Value != null))
{
SPParams[i+1] = OleDBCmd.Parameters[i].Value;
}
}
OleDBConn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return SPParams;
}
If that's not good idea for you, you can advice me. Thanks you all.