sql2014存储过程用VS2015调用存储过程保存数据

  SQL2014  先新建存储过程

sql2014存储过程用VS2015调用存储过程保存数据_第1张图片

 

 

 

private void button1_Click(object sender, EventArgs e)
        {
            String constr = "server=;database=;Persist Security Info=True;User ID=;Password=";
            SqlConnection con = new SqlConnection(constr);
            con.Open();
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandText = "hh1";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@FieldName", textBox1.Text); //设置参数并赋值

            cmd.Parameters.AddWithValue("@Condition", textBox2.Text);
            cmd.Parameters.AddWithValue("@A", textBox3.Text);
            if (cmd.ExecuteNonQuery() > 0)
            {
             
                MessageBox.Show("修改成功", "软件提示");
            }
            else
            {
             
                MessageBox.Show("修改失败", "软件提示");
            }
            con.Close();

        }

你可能感兴趣的:(sql2014存储过程用VS2015调用存储过程保存数据)