PC Review


Reply
Thread Tools Rate Thread

DEFAULT value in SqlParameter

 
 
Janaka
Guest
Posts: n/a
 
      9th Feb 2005
I'd like to submit the default value of a SQL column as the value to send in
my parameter. I know you can use DBNull.Value to enter NULLs. Is there a
way to enter the DEFAULT value?

i.e. in sql it would look something like UPDATE MyTable SET MyColumn =
DEFAULT

in .NET I want to write something like

SqlParameter myParam = new SqlParameter("@MyColumn", SqlDBType.Varchar, 20);
myParam.Value = Default.value;


 
Reply With Quote
 
 
 
 
Paul Clement
Guest
Posts: n/a
 
      9th Feb 2005
On Wed, 9 Feb 2005 17:46:21 -0000, "Janaka" <(E-Mail Removed)> wrote:

¤ I'd like to submit the default value of a SQL column as the value to send in
¤ my parameter. I know you can use DBNull.Value to enter NULLs. Is there a
¤ way to enter the DEFAULT value?
¤
¤ i.e. in sql it would look something like UPDATE MyTable SET MyColumn =
¤ DEFAULT
¤
¤ in .NET I want to write something like
¤
¤ SqlParameter myParam = new SqlParameter("@MyColumn", SqlDBType.Varchar, 20);
¤ myParam.Value = Default.value;
¤

Can't you just set the default value for the column at the database level and omit the parameter
from your update query?


Paul ~~~ (E-Mail Removed)
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
Janaka
Guest
Posts: n/a
 
      10th Feb 2005
Unfortuanately no. It is an optional field and may have user input or it
may not.


"Paul Clement" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Wed, 9 Feb 2005 17:46:21 -0000, "Janaka" <(E-Mail Removed)> wrote:
>
> ¤ I'd like to submit the default value of a SQL column as the value to
> send in
> ¤ my parameter. I know you can use DBNull.Value to enter NULLs. Is there
> a
> ¤ way to enter the DEFAULT value?
> ¤
> ¤ i.e. in sql it would look something like UPDATE MyTable SET MyColumn =
> ¤ DEFAULT
> ¤
> ¤ in .NET I want to write something like
> ¤
> ¤ SqlParameter myParam = new SqlParameter("@MyColumn", SqlDBType.Varchar,
> 20);
> ¤ myParam.Value = Default.value;
> ¤
>
> Can't you just set the default value for the column at the database level
> and omit the parameter
> from your update query?
>
>
> Paul ~~~ (E-Mail Removed)
> Microsoft MVP (Visual Basic)



 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      11th Feb 2005
On Thu, 10 Feb 2005 13:36:05 -0000, "Janaka" <(E-Mail Removed)> wrote:

¤ Unfortuanately no. It is an optional field and may have user input or it
¤ may not.
¤

I don't think I understand your reply. If you're using a default value when the field is not
specified then what different does it make whether you specify it at the query level, or the
database level?


Paul ~~~ (E-Mail Removed)
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sqlParameter Tony Johansson Microsoft C# .NET 4 30th Sep 2010 05:35 AM
Problem with SQLParameter data type (because 'System.Data.SqlClient.SqlParameter' is not derived from 'StoreBO.StoreBackOffice.SqlParameter'. ) Stacey Levine Microsoft VB .NET 3 16th Mar 2005 02:39 AM
default value assigned to SqlParameter that can be overwritten confused Microsoft C# .NET 2 15th Mar 2005 06:02 PM
Re: SQLParameter bug? Scott Allen Microsoft C# .NET 0 6th Sep 2004 06:51 PM
SqlParameter[] alex Microsoft ADO .NET 3 13th Apr 2004 08:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:47 AM.