Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


mapping to a varchar

Posted on 2004-10-27
Medium Priority
Last Modified: 2010-04-23
I have a parameter in a stored proc of type varchar. I create a sqlparameter to map to the varchar parameter. When do I have to specify the size of the parameter?
Question by:philjh
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 15

Expert Comment

ID: 12427896
' assume cmd is a SqlCommand object.
Dim p As New SqlParameter("@Parameter", SqlDbType.VarChar, 16)

You can specify the length as the third parameter, in my example I used 16.

Expert Comment

ID: 12427903
You shouldn't...just use something like:

oComm.Parameters.Add(New SqlParameter("@varAdjustment", SqlDbType.varchar)).Value = "Blah"

Author Comment

ID: 12431131
Thanks for the response. I can see that I can use the length, yet natloz suggests that I shouldn't. Why? I am trying to understand if there is a rule about when I should and when I shouldn't.

Accepted Solution

natloz earned 200 total points
ID: 12434022
As far as I have seen the length has not made a difference in my applications. It more than likely just uses a smaller amount of memory when you leave it wide open....as most programs do.

Author Comment

ID: 12733908
Sorry for the delay. Got sidetracked...

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question