473,569 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

set DataColumn.Defa ultValue to false

How can I set the DefaultValue property of DataColumn to false in C#

this.objdsMyDat aSet.tblMyTable .MyBooleanColum n.DefaultValue = false;

I have also tried setting it to System.Data.Sql Types.SqlBoolea n.False;

but in either case I get ArgumentExcepti on.

What is wrong, it looks straightforward to me.

thanks

Aamir
Nov 15 '05 #1
3 4244
What is the datatype of that column?

"Aamir Ghanchi" <aa**********@y ahoo.com> wrote in message
news:a6******** *************** ***@posting.goo gle.com...
How can I set the DefaultValue property of DataColumn to false in C#

this.objdsMyDat aSet.tblMyTable .MyBooleanColum n.DefaultValue = false;

I have also tried setting it to System.Data.Sql Types.SqlBoolea n.False;

but in either case I get ArgumentExcepti on.

What is wrong, it looks straightforward to me.

thanks

Aamir

Nov 15 '05 #2
It is a Bit Column (0/1)
I am doing this because the binded CheckBoxes on my form
cause problem when AddNew method of BindingManagerB ase is
used and the Position property does not get updated.

see this bug:
http://support.microsoft.com/default.aspx?scid=kb;en-
us;326440

I have also tried setting it to 0 (zero) besides false,
but get InvalidCastExce ption instead

-----Original Message-----
What is the datatype of that column?


Nov 15 '05 #3
Problem is Solved.

setting it to 0 (zero) did the work.
I was confusing this error with the similar error I was
getting for the DateTimePicker control which was being
bind to a smalldatetime column having <NULL> value for
that row.
I had to unbind the Value property of DateTimePicker
control from the smalldatetime column of the table and
that fixed it.

It would be nice in VS.Net if we get the exceptions that
point to the exact control causing the problem, but that
is not the case unfortunately. This exception was being
caused in some mscorlib.dll how would I know what to look
for. There are some still loose ends that Microsoft needs
to fix.

follwing is the exception I got in the MDIParent form, not
related to the actual ChilForm that had the problem
control on it:

An unhandled exception of
type 'System.Invalid CastException' occurred in mscorlib.dll

Additional information: Object cannot be cast from DBNull
to other types.

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3973
by: Craig Schneider | last post by:
// Is there any way to override the XML Serialization of the following SimpleClass // to turn off the DefaultValue of a boolean? Sure, I can override the DefaultValue from // true to false, but that is not what I want/need. I really need to just override the fact // that the developer ever supplied a DefaultValue. Setting an override...
0
1172
by: Juan Irigoyen | last post by:
As I can create a property in which they appear them name of the columns of a datatable object and when selecting selects the name of the column I have tried with the following code but when selecting it selects to the object column instead of the name of the column. Also I have proven has to use to typeconverter but I have not obtained...
1
1590
by: Azkaban | last post by:
Hi I succeded to add a DataColumn to DataSet but now I've one big problem. The value of this column would be a personal function result, I try a lot of time but the result is always empty. Why? There's a method to do this thing? This is the code cols = ImageDataSet.Tables("Immagini").Columns myCol = cols.Add() With myCol
5
1431
by: schneider | last post by:
Hello, Have an issue with a property using the DefaultValue(True) attribute. Imports System.ComponentModel Public Class Class1 Private m_testValue As Boolean
10
3276
by: tony | last post by:
Hello!! I have some demo programs written in C# and they have this construction "" see below. I haven't seen this before so what does it mean ? public bool ShowDropDownButtons { get { return showDropDownButtons; }
6
9379
by: Peter Hartlén | last post by:
Hi! What's the correct syntax for the default value design time attribute, using classdiagram view and Custom Attributes dialog. For a boolean: DefaultValue(true) DefaultValue("true") DefaultValue("bool","true")
1
7824
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I am note sure what to do because all propertiers work, except the System.Data.DataColumn.. I didn't write any code by hand and used the visual studio...
0
1684
by: Rainer Queck | last post by:
Hello NG, using the dataset designer, what is the right format to assigne a defaultvalue to DataColumn in the property editor? Thanks for help. Regards Rainer Queck
0
4524
by: SMH | last post by:
Hi All, I am currently learning .Net 2, studying for 70-528. I've hit a bit of a brick wall with DataColumn.Expression. As I understand it, this can be used to (For example) concatenate two columns to make a derived column. When I run my code, I get this error: ------------
0
7619
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...
0
7930
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, 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. ...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
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 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...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
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...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.