Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. nvarchar parameter of sql stored proc.

nvarchar parameter of sql stored proc.

Scheduled Pinned Locked Moved Database
databasequestioncsharpasp-nethelp
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Matthieu C
    wrote on last edited by
    #1

    Hi, I'm doing ASP.NET application. What is the type of the SqlParameter.Value to call a stored procedure expecting a nvarchar parameter? I tried to simply use a string, but it fails (code compiles, but the stored procedure returns nothing). I tried also to cast the string to a SqlDbType.Nvarchar, but I didn't manage. Thanks for help, sorry if I'm not clear ... Matthieu

    N 1 Reply Last reply
    0
    • M Matthieu C

      Hi, I'm doing ASP.NET application. What is the type of the SqlParameter.Value to call a stored procedure expecting a nvarchar parameter? I tried to simply use a string, but it fails (code compiles, but the stored procedure returns nothing). I tried also to cast the string to a SqlDbType.Nvarchar, but I didn't manage. Thanks for help, sorry if I'm not clear ... Matthieu

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      String should work. What does the stored proc look like?

      M 1 Reply Last reply
      0
      • N Not Active

        String should work. What does the stored proc look like?

        M Offline
        M Offline
        Matthieu C
        wrote on last edited by
        #3

        Hi, The procedure: ALTER PROCEDURE matthieu77.GetUserByName ( @Nom nvarchar ) AS SELECT UserID, Nom FROM Users WHERE Nom=@Nom RETURN The code that calls this proc: SqlParameter param = new SqlParameter ("@Nom",SqlDbType.NVarChar); param.Direction=ParameterDirection.Input; param.Value="Bonjour"; SqlDataAdapter ad = new SqlDataAdapter(); ad.SelectCommand = new SqlCommand(); ad.SelectCommand.Connection = sqlConnection1; ad.SelectCommand.CommandText = "GetUserByName"; ad.SelectCommand.CommandType =CommandType.StoredProcedure; ad.SelectCommand.Parameters.Add(param); ad.Fill(dataSet11,"Users"); DataGrid1.DataBind(); If I replace in the stored procedure Nom='Bonjour' it works fine. Regards, Matthieu

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups