473,766 Members | 2,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Column does not exist in DataTable Problem

Bob Ross
119 New Member
I have a very starange problem. I am trying to access a value from a datatable by specifying the column on the datarow but it keeps saying
"Column 'BitValue' is not cantained in table 'Fields'"
But it clearly is. All other columns work fine and I can reference it by number but not by name.

Expand|Select|Wrap|Line Numbers
  1. FieldsDS = FieldsSqlFactory.ExecuteQuery()
  2. FieldsDS.Tables(0).TableName = "Fields"
  3.  
  4. Dim AdditionalField As OrderingSpecificField
  5. Dim C As Integer = 0
  6. While C < FieldsDS.Tables(0).Rows.Count
  7.       Dim FR As DataRow = FieldsDS.Tables(0).Rows(C)
  8.  
  9.        'Check For which type of value & Build new Field by passing parameters to constructer
  10.         Select Case FR("FieldDataType")
  11.               Case "SpecificFieldDataType.bitValue"
  12.                   AdditionalField = New OrderingSpecificField(FR("ParentId"), FR("FieldIdentifier"), SpecificFieldDataType.bitValue, FR("FieldName"), FR("BitValue"), FR("TextValue"))
  13.               Case "SpecificFieldDataType.dateValue"
  14.                   AdditionalField = New OrderingSpecificField(FR("ParentId"), FR("FieldIdentifier"), SpecificFieldDataType.dateValue, FR("FieldName"), FR("DateValue"), FR("TextValue"))
  15.               Case "SpecificFieldDataType.floatValue"
  16.                   AdditionalField = New OrderingSpecificField(FR("ParentId"), FR("FieldIdentifier"), SpecificFieldDataType.floatValue, FR("FieldName"), FR("FloatValue"), FR("TextValue"))
  17.               Case "SpecificFieldDataType.intValue"
  18.                   AdditionalField = New OrderingSpecificField(FR("ParentId"), FR("FieldIdentifier"), SpecificFieldDataType.intValue, FR("FieldName"), FR("IntValue"), FR("TextValue"))
  19.               Case "SpecificFieldDataType.cboKeyValue"
  20.                   AdditionalField = New OrderingSpecificField(FR("ParentId"), FR("FieldIdentifier"), SpecificFieldDataType.cboKeyValue, FR("FieldName"), FR("CboKey"), FR("TextValue"))
  21.               Case Else
  22.                   AdditionalField = New OrderingSpecificField(FR("ParentId"), FR("FieldIdentifier"), SpecificFieldDataType.txtValue, FR("FieldName"), FR("TextValue"), FR("TextValue"))
  23.         End Select
  24.  
  25.         'add to Sample's collection of fields
  26.         SampleFields.Add(AdditionalField)
  27.         C += 1
  28. End While
It is the first case statement that causes problems.

If ANYONE could hepl I would much appreciate it.
Mar 6 '07 #1
2 2573
kenobewan
4,871 Recognized Expert Specialist
What database and platform are you using?
Mar 6 '07 #2
Bob Ross
119 New Member
Thanks for your reply.
But I got it working.
Stupid error managed to give the column a title of " BitValue" instead of "BitValue". DOH!
Mar 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
447
by: John Latten | last post by:
Hi there, I have got a problem when adding extra (= dummy) columns to a datagrid. I have a datagrid that is bound to a datatable. The datatable is filled with data from a SQL Server 2000 database. This data contains a column that is a foreign key to another table. In my datagrid I don't want to display this keyvalue. Instead I want to use this key to get a description out of another table. I have added an extra column to both the...
6
3248
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order entry application. The code below gets line items from a SQL Server database and returns them to a datagrid by way of a DataTable called lineTable. As long as I am just displaying columns in the SQL database everything works well. I now want...
2
7966
by: MattB | last post by:
I know I can use dataviews and more looping to do this, but I'm wondering if there's a more elegant or more concise way to do this. I've got two DataTables with a column called guest_no. I'd love to be able to use something like the .IndexOf method of arrays and bound controls. Somehting like: Dim r as DataRow For Each r in DataTable2.Rows If DataTable1.Columns("guest_no").IndexOf(r("guest_no")) <> -1
3
4224
by: Gene Hubert | last post by:
I'm using DataTable.ImportRow to move data from one datatable to another... Dim dt, dtTarget As DataTable Dim dr As DataRow dt = DirectCast(Me.DataSource, DataTable) dtTarget = dt.Clone 'copy the data structure dtTarget.DefaultView.Sort = String.Empty 'remove the sort
10
4953
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than the column order of the datatable). I also allow the user to click on a column header to sort the datagrid by that column. I need to identify the row and column in the datatable when the user clicks on a cell in the datagrid. Using the...
2
7359
by: RSH | last post by:
Hi, Iam struggling with an application where I am trying to transfer a datarow from one sql server to another instance of sql server. The schmeas may be slightly different and I am getting an exception when they are different. Is there anyway i can modify the code below so that if the schemas are different I can drop the offending column in the appropriate datatable? Thanks, Ron
1
2820
by: orenl | last post by:
I have a DataRow (from DataTable) and i want to get data from a column name that might not exist. public static object getObject(DataTable dataTable, int index, string columnName) { return dataTable.Rows; }
4
3514
by: =?Utf-8?B?TWlrZSBE?= | last post by:
I read the CSV file into a DataTable. This is so I can fix invalid dates and other data I don't want in the database. Then I use SqlBulkCopy to insert the data into the SQL database. All the rows are being read and inserted into the table. The problem is that one of the columns in the CSV contains the value of 1 thru 6 or C, BUT only the numbers seem to be read into the DataTable not the letter. I tried single quotes and double quotes...
9
6376
by: evan1979.2 | last post by:
I am creating a new boolean column in a MSAccess .mdb database like this: Dim Cmd As New OleDb.OleDbCommand("ALTER TABLE m_table ADD boolColumn YesNo", objConn) Cmd.ExecuteNonQuery() , which works fine. But... when the .mdb file is opened in Access the values for the new column are shown as "-1" and "0"...
0
9568
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
9404
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
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
10008
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...
1
9959
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9837
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8833
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
7381
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...
1
3929
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

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.