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

  • Home
  • SEARCH
  • 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 895245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:31:43+00:00 2026-05-15T14:31:43+00:00

2 Hi! I am trying to create stored procedure that gone return varchar value,

  • 0

2

Hi! I am trying to create stored procedure that gone return varchar value, and that value I need to display in textbox.

This is the code for stored procedure:

Create PROCEDURE Status @id_doc int, @Name varchar(50) OUTPUT
AS
select  @Name =items.name    
from Doc,Items where @id_doc=IDN and doc.IDN=Items.ID 
return @Name 

This is the code in vb.net where i need to display returned value from procedure in textbox:

Public Sub Current()
    Dim dtc As New Data.DataTable
    Dim dr As SqlClient.SqlDataReader
    Dim da As New SqlClient.SqlDataAdapter
    Dim cmd As New SqlClient.SqlCommand
    Dim id_doc As Integer
    Dim dset As New DataSet
    Dim recordset As DataRow
    Dim Name As String

    Try
        id_doc = idDocExplorer
        cmd.Connection = pubCon
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "Status"
        cmd.Parameters.Add("@id_doc", id_doc)
        cmd.Parameters.Add("@Name", SqlDbType.VarChar, 50)
        cmd.Parameters("@Name ").Direction = ParameterDirection.Output
        cmd.ExecuteScalar()

        Name = cmd.Parameters("@Name").Value
       TextBox1.text=Name
    Catch ex As Exception
        MsgBox(ex.Message)
    Finally
        dtc = Nothing
        dr = Nothing
        da = Nothing
    End Try
End Sub

When I try to execute this code I get this message in exception:

“Conversion failed when converting the varchar value ‘Blue color’ to data type int.”

What I am doing wrong? Thanks!

  • 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-15T14:31:43+00:00Added an answer on May 15, 2026 at 2:31 pm

    RETURN takes an integer argument only so return @Name is causing it

    Use this instead to return a record set (with a proper JOIN too)

    select
        items.name    
    from
        Doc
        JOIN
        Items ON doc.IDN = Items.ID 
    where
        @id_doc = IDN
    

    Although, it can be written like this too because @id_doc = doc.IDN = Items.ID:

    select
        items.name    
    from
        Items
    where
        Items.ID = @id_doc
    

    If you want to use an OUTPUT parameter rather than a recordset, then simply remove the RETURN statement and leave the assign to @Name

    ALTER PROCEDURE Status @id_doc int, @Name varchar(50) OUTPUT
    AS
    select @Name = items.name from Items where Items.ID = @id_doc
    GO
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a stored procedure that takes a bit parameter which
I'm trying to create a stored procedure that uses SELECT TOP 20 * from
I am trying to create a Stored Procedure that will be used for a
I need to create a stored procedure one time and in one place only
Is it possible to create a stored procedure that can call a function/generate C#
I am using SQL Server 2005. I want to create a stored procedure that
I'm having a never-ending problem with trying to call a stored procedure from a
I have created numbers of stored procedures in MySQL through remote access. And those
I'm a developer and I suck at SQL:) Please help me out here. I'd

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.