473,473 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Computed Columns in dataset always returning NULL

I am relativly new to visual basic, so this may be a no-
brainer.

I am attempting to use a computed column in a VB dataset
defined as followe:

'
'dcCost
'
Me.dcCost.ColumnName = "Cost"
Me.dcCost.DataType = GetType(System.Decimal)
Me.dcCost.Expression = "UnitPrice * Quantity"
Me.dcCost.ReadOnly = True

(IF this looks familiar, then youve probably taken MOC
2389B and done Lab 4)
So far this column only returns NULL after trying the
following:

Constructed the table and column in the visual editor.
Copied the code from the Solutions folder (cheating)
Loaded and ran the solution from the solutions folder.
Changed the expression to "6 + 3" to eleminate any
references to other columns.
Ran the code on another system with visual studio
installed.

I'm running Visual Studio.net 2003 and .net Framework 1.1.
Has anyone else encountered this or know the magic switch
to throw to enable the computed columns ?

Thanks,
Dave.
Nov 20 '05 #1
1 1901
Hi Dave:
"Dave" <an*******@discussions.microsoft.com> wrote in message
news:0d****************************@phx.gbl...
I am relativly new to visual basic, so this may be a no-
brainer.

I am attempting to use a computed column in a VB dataset
defined as followe:

'
'dcCost
'
Me.dcCost.ColumnName = "Cost"
Me.dcCost.DataType = GetType(System.Decimal)
Me.dcCost.Expression = "UnitPrice * Quantity"
Me.dcCost.ReadOnly = True

(IF this looks familiar, then youve probably taken MOC
2389B and done Lab 4)
So far this column only returns NULL after trying the
following:

Constructed the table and column in the visual editor.
Copied the code from the Solutions folder (cheating)
Loaded and ran the solution from the solutions folder.
Changed the expression to "6 + 3" to eleminate any
references to other columns.
Ran the code on another system with visual studio
installed.

I'm running Visual Studio.net 2003 and .net Framework 1.1.
Has anyone else encountered this or know the magic switch
to throw to enable the computed columns ?
Are you sure you have valid values in there? I'm thinking you may have
nulls and any operation on null = null. It doesn't equal anythign not even
Null or itself

This code works like a charm for me ( I created a table with Quantity and
Price as columns:

Dim ds As New DataSet
da2.Fill(ds, "PriceQuantity")
Dim dcTotal As New DataColumn("TotalPrice",
System.Type.GetType("System.Decimal"))
dcTotal.Expression = "Price * Quantity"
dcTotal.ReadOnly = True 'Don't really need this
ds.Tables(0).Columns.Add(dcTotal)
DataGrid1.DataSource = ds.Tables(0)
Thanks,
Dave.

Nov 20 '05 #2

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

Similar topics

2
by: tperovic | last post by:
Using SS2K, I'm getting the following error while bulk inserting: Column 'warranty_expiration_date' cannot be modified because it is a computed column. Here is my bulk insert statement: ...
9
by: DMAC | last post by:
If i want to split a computed column into two or more columns based on the the length (its a varchar) of the computed column, how often will sql server determine what the computed column is?...
2
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as...
4
by: Henning N?rg?rd | last post by:
I'm working as software developer mostely om SQL-server platform. On SQL-server we are using a lot of "Computed Columns" Does anyone know if that is possible to do in DB2 too ? I mean - define...
8
by: Brian | last post by:
This is causing me to not be able to create a relation in my dataset. Here's my code: dc1 = ds.Tables .Columns ; dc2 = ds.Tables .Columns ; dr1 = new System.Data.DataRelation...
3
by: BartMan | last post by:
Greetings, I have a gridview which is sitting on a multi view control (witin a view), and it is bound to a dataset which I dynamically apply to the control within asp.net page. The problem is...
4
by: Brad Baker | last post by:
I'm going a little crazy :) I'm trying to bind a repeater control to a dataset on page load using the following code: if (Request.QueryString != null) { string customerid = Request.QueryString;...
9
by: serge | last post by:
/* Subject: How to build a procedure that returns different numbers of columns as a result based on a parameter. You can copy/paste this whole post in SQL Query Analyzer or Management Studio...
7
by: Aamir Mahmood | last post by:
Hi All I have DataTable object. Is there a way that I can know which fields (columns) in the table are computed. Apparantly the DataTable.Columns returns all columns both computed and other....
0
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,...
0
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,...
0
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...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.