data insert using input output stored procedure

前端 未结 3 1470
说谎
说谎 2021-01-22 21:20

I am creating a web application using ASP.net C#. I have a booking form and I need to insert data into a table using a Stored Procedure. The table has several columns, out of wh

相关标签:
3条回答
  • 2021-01-22 22:04

    Use simple SqlCommand for calling your SP

    connection.Open();
    var cmd = new SqlCommand("sp_InsertCashPooja", connection);
    cmd.Parameters.AddWithValue("FirstName", frmFirstName);
    // Add all the others parameters in same way
    var id = (int)cmd.ExecuteScalar();
    connection.Close();
    
    0 讨论(0)
  • 2021-01-22 22:08

    Change the return variable to:

    Select @RcptNo = SCOPE_IDENTITY()
    

    It will return the identity number created for the inserted record within this procedure.

    0 讨论(0)
  • 2021-01-22 22:09

    use sql parameter..

    connection = ConfigurationManager.AppSettings["mycon"];

            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@stored procedure column name", string name);
            para[1] = new SqlParameter("@stored procedure column name", string name);
    
    0 讨论(0)
提交回复
热议问题