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 8743779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:44:16+00:00 2026-06-13T11:44:16+00:00

I used the following statement for a parameter. comm.Parameters.Add(@name, SqlDbType.NVarChar, 50).Value = txtname.Text; Name

  • 0

I used the following statement for a parameter.

comm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = txtname.Text;

Name is a SQL Server nvarchar column but I get this error:

Error converting data type nvarchar to numeric.

My sql:

SqlCommand comm = conn.CreateCommand();
comm.CommandText = "execute addName @name";
comm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = txtname.Text;

conn.Open();
comm.ExecuteNonQuery();
conn.Close();

Can help my to fix this problem?
My store procedure:

USE [info]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[addName]
            @id numeric(18,0) = 0,
            @name nchar(50)
as
if (select name from TName where name = @name) is null
begin
select @id =  MAX(id)+1 from TName
insert into TName
values (@id, @name)
print @id
end
else
begin
print 'Eroare'
end
  • 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-06-13T11:44:17+00:00Added an answer on June 13, 2026 at 11:44 am

    With the edit, with the signature:

    ALTER procedure [dbo].[addName]
            @id numeric(18,0) = 0,
            @name nchar(50)
    

    then the problem becomes clear:

    execute addName @name
    

    is pass-by-position – so you are passing the value of @name into the @id parameter. If you were calling this from TSQL, to pass-by-name you need to use:

    execute addName @name = @name
    

    The first (left) states the parameter name, the second (right) states the value to use for this parameter; for example, to pass a literal into addName‘s @name parameter:

    execute addName @name = 'Fred'
    

    However, from ADO.NET, a better approach is:

    comm.CommandText = "addName";
    comm.CommandType = CommandType.StoredProcedure;
    

    which automatically treats it as an SP-exec using pass-by-name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used the following statement for a parameter. .Parameters(@SearchValue).Value = TextBoxParentID.Text for this query:
I used the following create statement: CREATE TABLE `subscr` ( `id` int(11) NOT NULL
I used following code, but it displays only 2 digit of ISO country name.
I have read the following statement regarding to the comparison of C# value types
I'm having trouble getting a return value from SQL Server with the ID of
In many cases one needs the name of an expression, parameter, statement, etc. For
I have used the following statements to get the current time. print $query executed
I used following JS code to create equal height columns: var colHeight = Math.max($('.3columngallery
I have used following code to convert string to json and parse it. String
i have used following code to repeat a process creation/close iteratively dim vProcessInfo as

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.