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

x
?
Solved

mapping to a varchar

Posted on 2004-10-27
6
Medium Priority
?
221 Views
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?
0
Comment
Question by:philjh
[X]
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
6 Comments
 
LVL 15

Expert Comment

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

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

Expert Comment

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

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

Author Comment

by:philjh
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.
Thanks.
0
 
LVL 7

Accepted Solution

by:
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.
0
 

Author Comment

by:philjh
ID: 12733908
Sorry for the delay. Got sidetracked...
0

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