473,379 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

SQL Parameter Question

Hi ,

I want to make a stored proc call thru .NET . I use the SqlParameter objects
to create input parameters and set it's value.
SqlParameter myParameter = new
SqlParameter("@Description",SqlDbType.VarChar);
myParameter.Value = "some string size not known. but max size of the string
can be only 1024 characters";

Note : I have not mentioned the size of the parameter using
myParameter.Size = 1024;
My Question is what happens if i donot want to specify the Size for the
SqlParameter? Will it work properly. what is the default size .NET sets for
the SqlDbType.VarChar .

Thanx,

PK


Jul 21 '05 #1
1 1748
I'm not sure I understand your question...
However, why don't you pass the actual length of the string in the third
parameter of the CTOR:
SqlParameter("@Description",SqlDbType.VarChar,mySt ring.length);

For an input parameter, at execution time you will always know the length of
the string at the time you execute the line above

José

"Prashanth" <so*****@microsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi ,

I want to make a stored proc call thru .NET . I use the SqlParameter objects to create input parameters and set it's value.
SqlParameter myParameter = new
SqlParameter("@Description",SqlDbType.VarChar);
myParameter.Value = "some string size not known. but max size of the string can be only 1024 characters";

Note : I have not mentioned the size of the parameter using
myParameter.Size = 1024;
My Question is what happens if i donot want to specify the Size for the
SqlParameter? Will it work properly. what is the default size .NET sets for the SqlDbType.VarChar .

Thanx,

PK

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
3
by: Aguilar, James | last post by:
Hey all. I was making a newbie mistake that I eventually figured out. That is not my question. My question is about the error message. So let me set the stage for you: class Superclass {...
3
by: thomas goodwin | last post by:
I have a query which asks for a parameter value to execute it. To see the results I have to: a) click on the query -- the "Enter Parameter Value" window pops up. b) enter the parameter value c)...
6
by: hecsan07 | last post by:
I am writing some code that passes two parameters to a store procedure. One of the parameters is an output parameter. I am querying the DB using the input value and returning a field from the...
7
by: Britney | last post by:
Original code: this.oleDbSelectCommand1.CommandText = "SELECT TOP 100 user_id, password, nick_name, sex, age, has_picture, city, state, " + "country FROM dbo.users WHERE (has_picture = ?) AND (sex...
12
by: Darwin Lalo | last post by:
I have a lot of code like this: VOID CALLBACK TimerRoutine(PVOID lpParam) { long nTaskid = (long)lpParam; GObj *obj; if( mapThreadSafe.find( nTaskid, obj )) // mapThreadSafe is a hash_map,...
16
by: hzmonte | last post by:
Correct me if I am wrong, declaring formal parameters of functions as const, if they should not be/is not changed, has 2 benefits; 1. It tells the program that calls this function that the...
4
by: David Sanders | last post by:
Hi, I have a class with an integer template parameter, taking values 1, 2 or 3, and a function 'calc' in that class which performs calculations. Some calculations need only be performed if the...
6
by: HillBilly | last post by:
One question I have not figured out is how to learn which event parameter list is supported by a control? EventArgs, CommandEventArgs, what?
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.