look into SqlCommandBuilder or OleDbCommandBuilder 's DeriveParameters method, which populates the specified Command object's Parameters collection with parameter information for the stored procedure specified in the Command object
调试欢乐多
string strCnn = "Data Source=.;Initial Catalog=zy;User Id=sa;Password=";
SqlConnection myConnection =new SqlConnection(strCnn);
SqlCommand myCommand=new SqlCommand("sp_person", myConnection);
' 使用存储过程
myCommand.CommandType = CommandType.StoredProcedure;
' 向存储过程添加参数
SqlParameter prmEmail= new SqlParameter("@PersonEmail", SqlDbType.VarChar, 255);
prmEmail.Value = txtPersonEmail.Text;
myCommand.Parameters.Add(prmEmail); SqlParameter prmName=new SqlParameter("@PersonName", SqlDbType.VarChar, 255);
prmName.Value = txtPersonName.Text;
myCommand.Parameters.Add(prmName);
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
在调用存储过程的时候,用Reflection来得到这个QueryObject的每个属性的对应SQL Parameter的名称,类型,值等等信息
最后用楼上的方法建立SqlCommand对象