locked
Generate a code through SQL Procedure RRS feed

  • Question

  • User-1891900014 posted

    how do i generate a code out. 

    Eg. dropdownlist has M18/10

    After selecting it 

    M18/10/01 should ge be generated out in a textbox.

    If there is a M18/10/01 in the data.

    It will generate M18/10/02

    Friday, May 11, 2018 2:10 AM

Answers

  • User61956409 posted

    Hi JayRayJay,

    dropdownlist has M18/10. After selecting it, M18/10/01 should ge be generated out in a textbox.

    You can determine if the selected option is “M18/10” and assign the value to textbox on dropdown list OnSelectedIndexChanged event.

    If there is a M18/10/01 in the data. It will generate M18/10/02

    If you’d like to execute your SQL Procedure to from your ASP.NET web application, you can refer to the example in this article.

    SqlConnection con =  new SqlConnection(strConnString);
    SqlCommand cmd = new SqlCommand();
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "GetAllEmployeeDetails";
    cmd.Connection = con; 
    

    With Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 14, 2018 2:26 AM
  • User61956409 posted

    Hi JayRayJay,

    How Do i create the procedure?

    You can use CREATE PROCEDURE statement to create Transact-SQL stored procedure, following example is for your reference:

    USE AdventureWorks2012;  
    GO  
    CREATE PROCEDURE HumanResources.uspGetEmployeesTest2   
        @LastName nvarchar(50),   
        @FirstName nvarchar(50)   
    AS   
    
        SET NOCOUNT ON;  
        SELECT FirstName, LastName, Department  
        FROM HumanResources.vEmployeeDepartmentHistory  
        WHERE FirstName = @FirstName AND LastName = @LastName  
        AND EndDate IS NULL;  
    GO

    Besides, it will be better to ask one main topic/question in one thread. If the reply that I posted help you solve the original problem: executing SQL Procedure from ASP.NET web application and dynamically assign value to textbox, you can close the thread by marking it as answer, then if you have problem about creating SQL Procedure, you can ask it in a new thread.

    With Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 14, 2018 8:59 AM

All replies

  • User61956409 posted

    Hi JayRayJay,

    dropdownlist has M18/10. After selecting it, M18/10/01 should ge be generated out in a textbox.

    You can determine if the selected option is “M18/10” and assign the value to textbox on dropdown list OnSelectedIndexChanged event.

    If there is a M18/10/01 in the data. It will generate M18/10/02

    If you’d like to execute your SQL Procedure to from your ASP.NET web application, you can refer to the example in this article.

    SqlConnection con =  new SqlConnection(strConnString);
    SqlCommand cmd = new SqlCommand();
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "GetAllEmployeeDetails";
    cmd.Connection = con; 
    

    With Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 14, 2018 2:26 AM
  • User-1891900014 posted

    How Do i create the procedure? im new to SQL

    Monday, May 14, 2018 7:44 AM
  • User61956409 posted

    Hi JayRayJay,

    How Do i create the procedure?

    You can use CREATE PROCEDURE statement to create Transact-SQL stored procedure, following example is for your reference:

    USE AdventureWorks2012;  
    GO  
    CREATE PROCEDURE HumanResources.uspGetEmployeesTest2   
        @LastName nvarchar(50),   
        @FirstName nvarchar(50)   
    AS   
    
        SET NOCOUNT ON;  
        SELECT FirstName, LastName, Department  
        FROM HumanResources.vEmployeeDepartmentHistory  
        WHERE FirstName = @FirstName AND LastName = @LastName  
        AND EndDate IS NULL;  
    GO

    Besides, it will be better to ask one main topic/question in one thread. If the reply that I posted help you solve the original problem: executing SQL Procedure from ASP.NET web application and dynamically assign value to textbox, you can close the thread by marking it as answer, then if you have problem about creating SQL Procedure, you can ask it in a new thread.

    With Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 14, 2018 8:59 AM