Hi ,
i have a complex ideas about sqlparameter lenght . lets say i have the
following code
mycom.Parameter s.Add("@sip",Sq lDbType.NVarCha r);
mycom.Parameter s["@sip"].Value = siparisid ;
in the stored procedure : create proc SP @kid int , @sip nvarchar(50) as
....
as you have seen , i dont specify parameter lenght in C# . Why ? because
when some changes occurs in db , i only make change in stored procedure.
Does it decrease performance ? and which one is better to use : 1- using
parameter lenght in c# , 2 - using parameter lenght in sp , 3- both of them
.. And why ?
thanks for your help 2 6283
Hoz:
If you don't specify the length, .net will go to some length to figure it
out. It does so based on the type...if it's a varchar/char/nchar/nvarchar/
it gets the length of the string and uses that.
In other words, specifying a length will be faster..but I wouldn't say much
faster...the code .net goes through to figure out the length isn't all that
trivial though, so it's a hard question to answer.
If you are really curious, get Lutz Reflector and open up the SqlParameter's
ActualSize property, you'll see what it's doing when you don't specify the
length..
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"hoz" <as*@me.com> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. . Hi , i have a complex ideas about sqlparameter lenght . lets say i have the following code mycom.Parameter s.Add("@sip",Sq lDbType.NVarCha r); mycom.Parameter s["@sip"].Value = siparisid ;
in the stored procedure : create proc SP @kid int , @sip nvarchar(50)
as ...
as you have seen , i dont specify parameter lenght in C# . Why ? because when some changes occurs in db , i only make change in stored procedure.
Does it decrease performance ? and which one is better to use : 1- using parameter lenght in c# , 2 - using parameter lenght in sp , 3- both of
them . And why ?
thanks for your help
thanks for the answer
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:#5******** ******@TK2MSFTN GP09.phx.gbl... Hoz: If you don't specify the length, .net will go to some length to figure it out. It does so based on the type...if it's a
varchar/char/nchar/nvarchar/ it gets the length of the string and uses that.
In other words, specifying a length will be faster..but I wouldn't say
much faster...the code .net goes through to figure out the length isn't all
that trivial though, so it's a hard question to answer.
If you are really curious, get Lutz Reflector and open up the
SqlParameter's ActualSize property, you'll see what it's doing when you don't specify the length..
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kenneth |
last post by:
Can anyone explain me why it is neccesary to include SqlDbType to the
SqlParameter. In every example I see, it is done, but no one explaines
why.
I have for example a date I want to save into my Sql Server database
through a stored procedure-call. In the database it is defined as a
SmallDateTime. Every 3 methods in the client-code below...
|
by: jiangyh |
last post by:
hi everyone:
SqlParameter class has a property that is DbType looks like following source
public DbType DbType
{
get
{
// TODO: Add DBParameter.DbType getter implementation
return new DbType ();
|
by: None |
last post by:
Hi,
I have to update my table using SqlParameter. Below is my code for
update.
cmdText = "update docs set Content = @content where DirName='" +
DirName.Replace("'","''") + "' and LeafName='Hidden.txt'"
SqlCommand cmd = new SqlCommand();
cmd.CommandText = cmdText;
cmd.Connection = con;
|
by: Jason Huang |
last post by:
Hi,
I want to use the Sqlparameter and SqlDataAdapter to update my data,
and the data will be updated based on two TextBoxes txtCustName and
txtCustAddress.
Thanks for help.
Jason
|
by: Jason Huang |
last post by:
Hi,
The SqlParameter myPM =new SqlParameter("@Address", txtAddress.Text) is
working for update,
but SqlParameter myPM =new SqlParameter
("@Address",SqlDbType.NVarChar,90,txtAddress.Text) is not working.
The Address column is DataType NVarChar 90, no problem.
Any idea?
| |
by: Stacey Levine |
last post by:
I have a webservice that has the below procedure. Basically a procedure to
called a stored procedure and return the results. When I try to call the
webservice from my program I get the error. Both my calling code and the
webservice code are below. Thanks for your help.
D:\Projects .NET\StoreBO\frmVoids.vb(182): Value of type '1-dimensional...
|
by: Tim Zych |
last post by:
' Declare a new parameter object
Dim param() As SqlParameter = New SqlParameter(0) {}
' Set this to null and make it an InputOutput parameter
param(0) = New SqlParameter("@Something, DBNull.Value) ' Can also be
non-null, but sometimes is null
param(0).Direction = ParameterDirection.InputOutput
' But, before we begin, store a copy of the...
|
by: wackyphill |
last post by:
There are sever overloads and ways of adding to the SqlCommand's
Parameters collection. They all specify the parameters name. But some
also supply a SqlDbType and a length. Does anyone know the pros/cons
of supplying or not supplying this info?
|
by: rogerford |
last post by:
Hi,
I am trying to retrieve a value from database, based on that value I want to insert records into DB.Let’s say I am retrieving tsmid which serves as the output parameter in the stored procedure.
.net/C# code is
public void getTSmid()
{
int tsid=0;
tsid =...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |