public int addphoto(string file,int cateid)
{
//将文件名为file的文件读入到buffer中
System.IO.FileStream stream = new System.IO.FileStream(file, System.IO.FileMode.Open, System.IO.FileAccess.Read);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, (int)stream.Length);
stream.Close(); string strName = System.IO.Path.GetFileNameWithoutExtension(file); //调用sp_InsertPhoto存储过程,添加照片
SqlCommand cmd = new SqlCommand("sp_InsertPhoto", sqlConn);
cmd.CommandType = CommandType.StoredProcedure; SqlParameter param = cmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int);
param.Direction = ParameterDirection.ReturnValue;

cmd.Parameters.Add("@name", SqlDbType.VarChar).Value = strName;
cmd.Parameters.Add("@image", SqlDbType.Image).Value = buffer;
cmd.Parameters.Add("@album", SqlDbType.Int).Value = cateid; cmd.ExecuteNonQuery();

//获得返回的照片ID
int nID = (int)cmd.Parameters["RETURN_VALUE"].Value; //将照片添加到列表中
idList.Add(nID);
nameList.Add(strName);
descList.Add("");
searchMark.Add(0);
categoryList.Add(cateid);
timeList.Add("");

//buffer清空
buffer = null;

//更新视图,cateid参数表示照片属于的种类
dataUpdate("4",cateid);
return nID;
}
这个函数片段中用到了sqlparameter类型的对象,作用是传递参数到相应的SQL语句中,(其中的存储过程没有列出代码,还有几个全局变量声明也没列出来,因为我只去了一个函数片段)但是我就知道如下的传递方法:
  SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@CategoryID", guestCategory.CategoryID),
new SqlParameter("@CategoryName", guestCategory.CategoryName)
};               DBHelper.ExecuteCommand(sql, para);其中函数ExecuteCommand如下(为DBHelper类中的函数):
  public static int ExecuteCommand(string sql, params SqlParameter[] values)
        {
            SqlCommand cmd = new SqlCommand(sql, Connection);
            cmd.Parameters.AddRange(values);
            return cmd.ExecuteNonQuery();
        }
         
我想知道的是,第二中方法传递参数我看的很清楚,但是第一中参数的传递过程我很模糊,它到底是怎么个传递过程呢,
请人指点!两者的传递功能是相同的吗?