Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7668689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:25:26+00:00 2026-05-31T15:25:26+00:00

CREATE PROCEDURE [dbo].[proc1] ( @tbl1 varchar(30), @var2 varchar(7000) ) AS BEGIN DECLARE @sql VARCHAR(8000)

  • 0
CREATE PROCEDURE [dbo].[proc1]
(
    @tbl1   varchar(30),
    @var2   varchar(7000)
)
AS
BEGIN
    DECLARE @sql VARCHAR(8000)


    BEGIN
        SET @sql = 'INSERT INTO ' + @tbl1 + '(column) VALUES (''' + @var2 + ''')'

        EXEC (@sql)

        RETURN CONVERT(int, NEXT_IDENTITY(@tbl1))
    END
END

C# Method:

//create connection
using (AseConnection cn = new AseConnection(connectionString)) {
    AseCommand cmd = new AseCommand();

    AseParameter[] paras = new AseParameter[]{
        new AseParameter("@tbl1", AseDbType.VarChar, 30), 
        new AseParameter("@var1", AseDbType.VarChar, 7000),
        new AseParameter("@RetValue",AseDbType.Integer) };
    // Add all the parameters to command object
    foreach(AseParameter p in  paras) {
        cmd.Parameters.Add(p);
    }

    //finally, execute the command.
    return cmd.ExecuteNonQuery();
}

However, the third parameter is always empty. If I execute procedure directly in Sybase client, it gives me correct value.
Does anyone have good suggestion how to solve this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:25:27+00:00Added an answer on May 31, 2026 at 3:25 pm

    Declare the third parameter as

    AseParameter retParam = new AseParameter("@RetValue",AseDbType.Integer);
    retParam.Direction = ParameterDirection.ReturnValue;
    

    Also, select the identity with

    RETURN @@identity
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

CREATE PROCEDURE [dbo].[PL_GEN_PROVN_NO1] @GAD_COMP_CODE VARCHAR(2) =NULL, @@voucher_no numeric =null output AS BEGIN DECLARE @NUM
I have this proc: Create PROCEDURE [dbo].[myProc] @TableName nvarchar(100), @RowID int AS BEGIN SET
In Microsoft Sql it is possible to encrypted stored procedures with CREATE PROCEDURE dbo.foo
I have a stored procedure as follows: CREATE PROC [dbo].[Incidents] (@SiteName varchar(200)) AS SELECT
CREATE PROCEDURE [dbo].[FlowClientGetNum] (@ID_ListGroupParIzm Integer, @ID_ListParIzm Integer) AS SELECT Number of my @ID_ListParIzm FROM
I have a stored procedure that looks like: CREATE PROCEDURE dbo.usp_TestFilter @AdditionalFilter BIT =
I have created the following stored procedure.. CREATE PROCEDURE [dbo].[UDSPRBHPRIMBUSTYPESTARTUP] ( @CODE CHAR(5) ,
I have an SQL CREATE PROCEDURE statement that runs perfectly in my local SQL
I have the fallowing stored procedure: CREATE PROCEDURE `get`(IN tb VARCHAR(50), IN id INTEGER)
I have the following SP CREATE PROCEDURE GetAllHouses set @webRegionID = 2 set @sortBy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.