473,387 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DataTable.Expressions really not working

Hi all, I have a DataTable im trying to filter, however I simply cannot get
what appears to be a simply expression to work.

Int cartId = 15;
string expression = "cartId =" + cartId;
DataRow[] test = myDataTable.Select(expression);

This always returns no datarows. However, if I hard code the expression
("cartId = 15") it works fine. How can I get my parameter to work?? i have
tried Convert.ToInt32(...), etc etc. The datatype is Int32.

Please help.

Kind regards
Taz
Sep 16 '06 #1
1 1588
First, does the code you have even work. You are not casting cartId to
string and C# should not compile a non-explicit string conversion. Debug and
check your expression and you might find your problem.

ANother way of doing what you desire is a DataView with a filter expression.
It is not that much different and allows you to bind the same raw data to
many different controls.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
"Tarun Mistry" <no****@nospam.comwrote in message
news:O2****************@TK2MSFTNGP04.phx.gbl...
Hi all, I have a DataTable im trying to filter, however I simply cannot
get what appears to be a simply expression to work.

Int cartId = 15;
string expression = "cartId =" + cartId;
DataRow[] test = myDataTable.Select(expression);

This always returns no datarows. However, if I hard code the expression
("cartId = 15") it works fine. How can I get my parameter to work?? i have
tried Convert.ToInt32(...), etc etc. The datatype is Int32.

Please help.

Kind regards
Taz

Sep 16 '06 #2

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

Similar topics

1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
7
by: mark | last post by:
Access 2000: I creating a report that has a record source built by the user who selects the WHERE values. An example is: SELECT * FROM CHARGELOG WHERE STDATE Between #10/27/2003# And...
2
by: Michael Howes | last post by:
I have a single DataTable in a DataSet. It has 4 columns and i'd like to get a handful of counts of unique items in 3 of the 4 columns. Can a DataTables Select or Compute methods to COUNT DISTINCT?...
9
by: VMI | last post by:
We have this huge application that's based on storing tons of data on a dataTable. The only problem we're having is that storing LOTS of data (1 million records) into a datatable will slow down the...
1
by: Mike | last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the course of about 3 different pages. On the way out of the first of these pages, I explicitly build the DataTable from values in...
0
by: John | last post by:
Hey, all - Context: I'm working on a project where I'm storing a relatively small amount of 'featured' product information in cache - about 30 records, not updated very frequently. They get...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
6
by: ronchese | last post by:
Hi. I'm trying to make a criteria string to use in Select() method of a datatable, searching for a date, but it is apparently not working! In one of my tests, I have a datatable with 1 row and...
9
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I've got a routine that builds a table using different queries, different SQL Tables, and adding custom fields. It takes a while to run (20 - 45 seconds) so I wrote a thread to handle the table...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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,...

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.