473,396 Members | 2,010 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,396 software developers and data experts.

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

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
5 1577
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
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
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dave | last post by:
Hello all, Unfortunately, the reference I have is a bit slim on describing how to create user-defined exceptions derived from std::exception. I think what I have below will work, but is it the...
4
by: Jesse Elve | last post by:
I am using an XmlValidatingReader which uses an XSD for xml validation. The code has been performing reliably for months. Yesterday it failed for the first time with the following exception: ...
1
by: philipl | last post by:
hi, I have a pluggin whiich throw an exception of the following user defined exception: public class SpellCheckException : ApplicationException { public SpellCheckException(string msg) :...
2
by: Stressed Out Developer | last post by:
We have an application that has a 200 count loop that does the following: ' Each time thru the loop we pass the next IP Address is a range (aka 192.168.4.50 thru 192.168.4.254) Try If...
5
by: Rob Dob | last post by:
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...
7
by: Mark Rae | last post by:
Hi, Has anyone successfully used the FTP stuff in the System.Net namespace against a VMS FTP server? I'm trying to do this at the moment and can't even get a directory listing, although there...
9
by: Robert Bravery | last post by:
HI all, I have a column value returned to a string variable in my c# app. But the return type is of system.dbnull. How can I convert that to a system.sting Thanks Robert
13
by: lithoman | last post by:
I'm stumped here. I run the procedure Batch_Select against the database with @ID=18 and I get the expected data. When it loads into a SqlDataReader, it gets messed up somehow. Initially, after the...
7
oll3i
by: oll3i | last post by:
i want to change the values in two columns one colum is a combobox and the secons column is editable too i want to get the value of that second column and the value of combobox and sent that...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
0
tracyyun
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.