Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / August 2006

Tip: Looking for answers? Try searching our database.

Question about SqlCommand.Parameters.Add() method.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pedestrian - 30 Aug 2006 08:44 GMT
I'm currently programming an ADO.NET application for SQL server.
I notice that the SqlCommand.Paraterers.Add() method require 4 parameters
which are parameterName, SqlDbType, Size, and SourceCOlumn. The question is
with Size parameter:

What is the corrent Size value for SqlDbType.Int, SqlDbType.Money and
SqlDbType.Real? I'm adding those type to the method.

Thanks...

Signature

Regards,
Pedestrian, Penang.

Otis Mukinfus - 30 Aug 2006 12:18 GMT
>I'm currently programming an ADO.NET application for SQL server.
>I notice that the SqlCommand.Paraterers.Add() method require 4 parameters
[quoted text clipped - 5 lines]
>
>Thanks...

If you use this overloaded method the length will be provided:

public SqlParameter Add (string parameterName,
    SqlDbType sqlDbType)

or you can use the AddWithValue method:

public SqlParameter AddWithValue (string parameterName,
    Object value)

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
pedestrian - 31 Aug 2006 01:18 GMT
Thanks for replying, Otis.

I'm using the 4 parameters overload method because I like to specify the
SourceColumn (in Sql server).
I found that Sp_help in Sql Server give the length of the type, is the length
the answer to the Size value in SqlParameter.Add method?

Signature

Regards,
Pedestrian, Penang.

Otis Mukinfus - 31 Aug 2006 10:33 GMT
>Thanks for replying, Otis.
>
>I'm using the 4 parameters overload method because I like to specify the
>SourceColumn (in Sql server).
>I found that Sp_help in Sql Server give the length of the type, is the length
>the answer to the Size value in SqlParameter.Add method?

Yes.  Please excuse my poor choice of words :o)
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
William (Bill) Vaughn - 31 Aug 2006 18:44 GMT
When the overloads don't have the right mix of property settings we have to
resort to multiple property set operations. You might just try setting the
length to the size of the Integer as stated in the help or 0. I expect it's
ignored anyway.

Signature

____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

> Thanks for replying, Otis.
>
[quoted text clipped - 3 lines]
> length
> the answer to the Size value in SqlParameter.Add method?
pedestrian - 01 Sep 2006 00:45 GMT
Thanks Otis. All to best to you...

Thanks William. I guess you are right. I did set the Size to 8 for SqlDbType.
Int unintentionally and
it don't show me the error...

Have a nice days, guys.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.