标签:io ar 数据 cti sp on c ad new
protected void btnQuery_Click(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)) { using (SqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "test2"; cmd.CommandType = CommandType.StoredProcedure; con.Open(); SqlParameter id = new SqlParameter("@id", SqlDbType.TinyInt); id.Value = txtId.Text; id.Direction = ParameterDirection.Input; cmd.Parameters.Add(id); SqlParameter name = new SqlParameter("@name", SqlDbType.VarChar, 20); name.Direction = ParameterDirection.Output; cmd.Parameters.Add(name); SqlParameter age = new SqlParameter("@age", SqlDbType.TinyInt); age.Direction = ParameterDirection.Output; cmd.Parameters.Add(age); // cmd.ExecuteNonQuery(); // lblResult.Text = "姓名:" + name.Value + "\n" + "年龄:" + age.Value; SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { lblResult.Text = "姓名:" + name.Value + "\n" + "年龄:" + age.Value; } else { lblResult.Text = "没有数据"; } } } }
标签:io ar 数据 cti sp on c ad new
原文地址:http://www.cnblogs.com/lschenblog/p/3964081.html