protected void btn_Add_Click1(object sender, EventArgs e) { try { // Connection to the database // // string str; str = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString; SqlConnection sqlCon = new SqlConnection(str); // Call the stored procedure SqlCommand sqlCmd = new SqlCommand("sp_Trial", sqlCon); sqlCmd.CommandType = System.Data.CommandType.StoredProcedure; // Create and supply the output parameters sqlCmd.Parameters.Add("@LoanID", System.Data.SqlDbType.VarChar, 10); sqlCmd.Parameters["@LoanID"].Direction = System.Data.ParameterDirection.Output; // Open the sql data connection sqlCon.Open(); // Execute the stored procedure sqlCmd.ExecuteNonQuery(); lblstatus.Text = "Student details saved successfully"; // Assign the results to the controls txt_Int_Code.Text = sqlCmd.Parameters["@LoanID"].Value.ToString(); // // sqlCon.Close(); } catch (Exception ex) { lblstatus.Text = ex.Message; }
USE [COC_CREDIT] GO /****** Object: StoredProcedure [dbo].[sp_Trial] Script Date: 05/25/2014 12:22:20 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER Procedure [dbo].[sp_Trial] ( @LoanID varchar(10) Output ) As Begin Declare @SID Smallint Select @SID = ISNULL(MAX(CONVERT(SMALLINT,SUBSTRING(INT_NO,4,6))),0) + 1 From INTEREST Select @LoanID = 'INT' + REPLICATE('0',6 - LEN(@SID)) + CONVERT(VARCHAR(6),@SID) End
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)