By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,052 Members | 1,303 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,052 IT Pros & Developers. It's quick & easy.

For columns not defined as System.String, the only valid value is (Throw exception).

P: n/a
I am trying to set the NullValue within the Column properties of my Dataset
in VS2005. The DataType is a System.DateTime. and when I try and change it
from "(Throw Exception)" I get the following error:

For columns not defined as System.String, the only valid value is (Throw
exception).

The Datafield is a datetime that allows nulls, if I don't set this value
then when I try save changes to this field within my form I get it
complaining about not allowing DBNull for that field..

I am also having this same problem with DataType int where I also allow
nulls

any help would be appreciated.,
Sep 25 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Rob,

First, can we see the code where you are assigning your null to your
datarow?
Secondly, is the dataset a 'typed' dataset?
And finally, what database are you using?

Cheers,
Steven

Sep 25 '06 #2

P: n/a
Hi,

I have a DateTimePicker Databound to Dataset datacolumn whicc allow nulls:

And before I call update on my tableadapter I do something like: where ( ordersCustomersRow ) is a view of two combined tables.
ordersRow.Permit_Date = ordersCustomersRow.Permit_Date;

I'm using MSSQL2005

Sep 25 '06 #3

P: n/a
Mel
I set it using parameters, something like
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "Update Policys set ExpDate = @ExpDate where
primaryKey = @primaryKey";
cmd.Parameters.Add("@ExpDate", SqlDbType.DateTime).Value = DBNull.Value;
cmd.Parameters.Add("@primaryKey", SqlDbType.Int).Value = 100;
}

"Rob Dob" <ro************@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I am trying to set the NullValue within the Column properties of my Dataset
in VS2005. The DataType is a System.DateTime. and when I try and change it
from "(Throw Exception)" I get the following error:

For columns not defined as System.String, the only valid value is (Throw
exception).

The Datafield is a datetime that allows nulls, if I don't set this value
then when I try save changes to this field within my form I get it
complaining about not allowing DBNull for that field..

I am also having this same problem with DataType int where I also allow
nulls

any help would be appreciated.,


Sep 25 '06 #4

P: n/a

Hi,
>I set it using parameters, something like
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "Update Policys set ExpDate = @ExpDate where
primaryKey = @primaryKey";
cmd.Parameters.Add("@ExpDate", SqlDbType.DateTime).Value =
DBNull.Value;
cmd.Parameters.Add("@primaryKey", SqlDbType.Int).Value = 100;
}
I would prefer to just set the value within my strongly typed dataset before
I call its TableAdaptersUpdate(), is this possible?

Thanks,
Sep 25 '06 #5

P: n/a
Hi,
>"Rob Dob" <ro************@yahoo.comwrote in message
news:OY**************@TK2MSFTNGP06.phx.gbl...
Hi,
>I have a DateTimePicker Databound to Dataset datacolumn whicc allow nulls:
And before I call update on my tableadapter I do something like: where
( ordersCustomersRow ) is a view of two combined tables.
ordersRow.Permit_Date = ordersCustomersRow.Permit_Date;
Try something like:

if ( ordersCustomersRow.IsPermit_DateNull() )
odersRow.SetPermit_DateNull()
else
ordersRow.Permit_Date = ordersCustomersRow.Permit_Date

Or simply untyped:

ordersRow["Permit_Date"] = ordersCustomerRow["Permit_Date"];

HTH,
Greetings

I'm using MSSQL2005

Sep 26 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.