PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 3.00 average.

Set dataset element default value to empty string

 
 
moondaddy
Guest
Posts: n/a
 
      25th Mar 2004
I'm using vb.net 1.1 and VS2003. in the dataset designer I'm trying to set
the default value of a dataset table column (actually its an attribute) to
an empty string so I don't get dbnull error in my code. How can I do this.
In databases I can set a default value of empty string by using 2 quotes
("") but if I do that here the return value is literally 2 quotes ("""").
Any good ideas?

Thanks.

--
(E-Mail Removed)


 
Reply With Quote
 
 
 
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      25th Mar 2004
Hi moondaddy,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to set the default value of a
DataColumn to an empty string at design time. If there is any
misunderstanding, please feel free to let me know.

This can be achieved by setting the default attribute for the column. Here
are the steps:

1. In the DataSet Designer, switch to XML view for the DataSet.
2. Find the element for the corresponding column. For example, I'm going to
set default value for a column named "ShipName". The element in the schema
might look like the following:
<xs:element name="ShipName" type="xs:string" minOccurs="0" />
3. Now we add the default attribute to the element, using default="".
<xs:element name="ShipName" type="xs:string" minOccurs="0" default ="" />

Now the default value has been set to an empty string.

For more information, please check the following link:
http://msdn.microsoft.com/library/de...us/xmlsdk/htm/
xsd_ref_9ugk.asp

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 
Reply With Quote
 
 
 
 
moondaddy
Guest
Posts: n/a
 
      25th Mar 2004
Thanks that work really good. I don't know why I didn't think of that.

--
(E-Mail Removed)
"Kevin Yu [MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi moondaddy,
>
> First of all, I would like to confirm my understanding of your issue. From
> your description, I understand that you need to set the default value of a
> DataColumn to an empty string at design time. If there is any
> misunderstanding, please feel free to let me know.
>
> This can be achieved by setting the default attribute for the column. Here
> are the steps:
>
> 1. In the DataSet Designer, switch to XML view for the DataSet.
> 2. Find the element for the corresponding column. For example, I'm going

to
> set default value for a column named "ShipName". The element in the schema
> might look like the following:
> <xs:element name="ShipName" type="xs:string" minOccurs="0" />
> 3. Now we add the default attribute to the element, using default="".
> <xs:element name="ShipName" type="xs:string" minOccurs="0" default ="" />
>
> Now the default value has been set to an empty string.
>
> For more information, please check the following link:
>

http://msdn.microsoft.com/library/de...us/xmlsdk/htm/
> xsd_ref_9ugk.asp
>
> HTH. If anything is unclear, please feel free to reply to the post.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



 
Reply With Quote
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      25th Mar 2004
Hi moondaddy,

You're welcome. Thanks for sharing your experience with all the people
here. If you have any questions, please feel free to post them in the
community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 
Reply With Quote
 
Benny Tordrup
Guest
Posts: n/a
 
      29th Mar 2004
Kevin,

According to Microsoft Knowledgebase Article 325691, the default value
element is not serialized. I tried the same with no result using Visual
Studio 2003.

Reference: http://support.microsoft.com/default...b;en-us;325691

Best regards,

Benny Tordrup

"Kevin Yu [MSFT]" <(E-Mail Removed)> skrev i en meddelelse
news:(E-Mail Removed)...
> Hi moondaddy,
>
> First of all, I would like to confirm my understanding of your issue. From
> your description, I understand that you need to set the default value of a
> DataColumn to an empty string at design time. If there is any
> misunderstanding, please feel free to let me know.
>
> This can be achieved by setting the default attribute for the column. Here
> are the steps:
>
> 1. In the DataSet Designer, switch to XML view for the DataSet.
> 2. Find the element for the corresponding column. For example, I'm going

to
> set default value for a column named "ShipName". The element in the schema
> might look like the following:
> <xs:element name="ShipName" type="xs:string" minOccurs="0" />
> 3. Now we add the default attribute to the element, using default="".
> <xs:element name="ShipName" type="xs:string" minOccurs="0" default ="" />
>
> Now the default value has been set to an empty string.
>
> For more information, please check the following link:
>

http://msdn.microsoft.com/library/de...us/xmlsdk/htm/
> xsd_ref_9ugk.asp
>
> HTH. If anything is unclear, please feel free to reply to the post.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



 
Reply With Quote
 
New Member
Join Date: Apr 2011
Posts: 1
 
      14th Apr 2011
Hi All,

I used following xsd

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Rules">
<xs:complexType>
<xs:sequence>
<xs:element name="Rule" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="username" type="xs:string" minOccurs="0" default =""/>
<xs:element name="password" type="xs:string" minOccurs="0" default =""/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>


when I try to print the user name value I am getting null values
could you please suggest me on this
 
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
Routing WCF Calls based on Body Element - How to rout empty element? Tino Donderwinkel Microsoft C# .NET 0 7th Aug 2010 09:59 AM
Element 'Element Name Here' is not a known element. This can occur if there is a compilation error in the Web M Noreen Microsoft Dot NET 3 17th Apr 2006 07:28 AM
string.Empty or String.Empty or ""? Charlie@CBFC Microsoft C# .NET 6 5th Feb 2006 08:10 AM
<table> element with <table> element ... loading dataset timnels@gmail.com Microsoft C# .NET 0 23rd Jun 2005 03:01 PM
bug with <li> element included in inline element karlis Windows XP Internet Explorer 1 18th Aug 2003 02:38 AM


Features
 

Advertising
 

Newsgroups
 


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