473,699 Members | 2,514 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 4251
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
3996
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 DefaultValue of null // or "new object()" errors. Any help would be appreciated.
0
1177
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 anything. Thanks. private DataColumn formCampoClave = null;
1
1596
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
1437
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
3303
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
9381
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
7840
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 to set the properties..
0
1688
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
4557
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
8687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9174
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7751
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6534
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5875
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2009
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.