Call a stored procedure with parameter in c#

前端 未结 7 895
闹比i
闹比i 2020-11-22 16:16

I can do a delete, insert and update in my program and I try to do an insert by call a created stored procedure from my database.

This a button insert I make work

7条回答
  •  难免孤独
    2020-11-22 16:48

    public void myfunction(){
            try
            {
                sqlcon.Open();
                SqlCommand cmd = new SqlCommand("sp_laba", sqlcon);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.ExecuteNonQuery();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                sqlcon.Close();
            }
    }
    

提交回复
热议问题