Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3390750
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:43:38+00:00 2026-05-18T03:43:38+00:00

Background information first: We are using a strongly-typed DataSet to manage transaction files. That

  • 0

Background information first:

We are using a strongly-typed DataSet to manage transaction files. That is to say, the DataSet does not use a database of any kind as its backing store; instead the DataSet is used to read and write XML files to disk. The WriteXml(fileName As String) is used to output specific rows of data, and all dependant rows from other tables are automatically embedded in the output.

The ReadXml method is used to load these files at startup time.

Originally, the classes for this were generated with a code-gen tool in VB.NET. However, since this system was put in place, many manual modifications have been made. i.e. regenerating the classes is not really an option at this point (Boo and hiss all you like; I didn’t do it).

A customer who uses our system in the field has run accross an odd exception; one that we can’t readily reproduce. Basically, a case occurred where the system was trying to read the value of a transaction already in the DataSet, and it resulted in an “InvalidCastException”.

(BTW: Our system runs on a streamlined WinCE system, using the Compact Framework v3.5; since it’s bare-bones, the CAB file that gives exception message is not installed, but given its context, I can make a good guess…)

If I understand correctly, this should happen when a strongly-typed property is accessed from the DataSet that has a DBNull value.

If this was all there was to it, I wouldn’t be writing this.

However, the column is question has its “AllowDBNulls” property set to False. I’ve checked and re-checked this, and confirmed that it is being set to False.

So… shouldn’t this be impossible? How can an InvalidCastException occur when this property is set as False?

Here’s some code-snippets do show what we’re doing to setup the column:

Private Sub InitClass()
    'Snip...'
    Me.columnTransactionMode = DatasetUtilities.addColumn(Me.Columns, "transactionMode", GetType(System.Int32), False, False)
    'Snip...'
End Sub

The DatasetUtilities.addColumn method:

Friend Shared Function addColumn(ByRef columns As Data.DataColumnCollection, _
                                    ByRef columnName As String, ByRef type As Type, _
                                    ByRef allowDBNull As Boolean, ByRef isUnique As Boolean) As Data.DataColumn
    Dim column As Data.DataColumn

    column = New Data.DataColumn(columnName, type, Nothing, System.Data.MappingType.Attribute)
    columns.Add(column)
    column.AllowDBNull = allowDBNull
    column.Unique = isUnique

    Return column
End Function

The transactionMode property on the CustomerTransactionRow class:

Public Property transactionMode() As Integer
    Get
        Return CType(Me(Me.tableCustomerTransaction.transactionModeColumn), Integer)
    End Get
    Set(ByVal Value As Integer)
        Me(Me.tableCustomerTransaction.transactionModeColumn) = Value
    End Set
End Property

This is the first and only report of this issue that we’ve had to-date. I’m going to protect against this happening again as best as I can with exception handling. However, I’d feel a lot better if I knew exactly why the issue occurred.

Thanks for your time, all!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:43:38+00:00Added an answer on May 18, 2026 at 3:43 am

    Try setting a default value for any columns that don’t allow NULLs. I recently had a similar situation where AllowDBNull was set to false but columns in new rows still contained NULL if no default was specified. AFAIK this is normal behavior. In my case setting the default value or explicitly setting the value in any new rows solved the problem.

    Cheers!
    JE

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As usual, some background information first: Database A (Access database) - Holds a table
Background: At my company we are developing a bunch applications that are using the
And if you do, can you give some background information on the implementation and
Background I am writing and using a very simple CGI-based (Perl) content management tool
Background Information: Visual Studio 2010 (.NET Framework 4.0) Informix Server 7.31 Informix ClientSDK 3.50
A bit of background information: Inorder to read/write to SLE4442 memory cards, my app
A little background information: I have a table called table_a , which has 12
First, a bit of my background. I have been working on large web systems
I am developing a simple web apps that allowed user to key in information
I know that I can use the component parts of the date helpers, rather

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.