473,761 Members | 8,813 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running Select query against dataTable

VMI
How can I run a Select query from a datatable so that it only brings the
fields I want? For example, if my datatable has 30 fields, a query would be
"select custId, Name" because those are the only two fields I need. Then I'd
like to put the result in another datatable.

Thanks.
Nov 16 '05 #1
1 14479
VMI,

You can't perform selects in that manner from a DataTable. The best you
can do is call the Select method, and pass a filter based on column values
(the documentation for the Select method will tell you how you can construct
a filter). Once you do that, you can take the rows returned, and copy only
the columns you want from each row to a new data table.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"VMI" <vo******@yahoo .com> wrote in message
news:Om******** ********@tk2msf tngp13.phx.gbl. ..
How can I run a Select query from a datatable so that it only brings the
fields I want? For example, if my datatable has 30 fields, a query would
be "select custId, Name" because those are the only two fields I need.
Then I'd like to put the result in another datatable.

Thanks.

Nov 16 '05 #2

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

Similar topics

3
5224
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and includes the following columns: DocID (INTEGER, PRIMARY KEY, CLUSTERED) IsRecord (INTEGER, NONCLUSTERED)
1
2384
by: microsoft.news.com | last post by:
is it possible to run a SELECT statement against a datatable, and if so how? this is what i have, its populating an excel document, I have my dataset, creatig a data table, now i need to group the data from the data set so i see the data like this: I looked at using a hashtable and for what i need it won't work correctly Delaware Dover Wilmington New Castle
1
2243
by: Adam Clark | last post by:
Hi Is it possible to run a query against a dataset. For example, I want to create a new table and I read somewhere that ADO.NET does not support creating tables in access without the use of sql statements. Any examples you could provide would be appreciated. Thanks Adam
6
4848
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID SalesManName AT Alan Time
3
1970
by: phonl | last post by:
I am a vb6 ADO developer looking at vb.net 2005 and ADO2.net. I used the vb.net 2005 data wizard to bind some controls to a database. Now I want to run a select query and have the bound controls reflect the change from the query. How would I do that? The wizard created a TableAdapter, BindingSource, and DataSet. Somehow I need to run feed them a select query to update the data.
1
3669
by: jasonlakewhitney | last post by:
I have an MDB on my PC with 3 linked tables to a SQL database. I only have permissions on the SQL db to insert and delete records. The linked tables are LnktblA, LnktblB, LnktblC and the main MDB tables are tblA, tblB, tblC. is (<-- one to many --oo) The relationships in SQL LnktblA<----ooLnktblB<----ooLnktblC. The relationships in mdb tblA<----ootblB<----ootblC. All relationships have: (SQL and MDB) Enforced relationship for...
9
4021
by: JJM0926 | last post by:
I'm trying to create a running totals query in access 97. I have followed the directions on how to do it from Microsofts website article id 138911. I took their code they had and replaced it with my fields. When I try to run it I get #errors in my RunTot column. I'm kinda new to this. Not sure if maybe I mistyped something wrong or is there a better way to do this? I have pasted the code. Any help would be greatly appreciated....
2
9036
by: DotNetDanjo | last post by:
I want a stored procedure to run a select query on it's own like this: Select *, user_id As UserId FROM CC_host.dbo.usr_table Where(email LIKE N'%@%usa.com') But from these results I want the same stored procedure to INSERT any new records (user_id as primary key) into the next table.. If Not Exists (Select As UserId2 From Usr_Type_Data WHERE UserId2 = UserId) INSERT INTO Usr_Type_Data (user_id, CustomerTypeId) VALUES(t1.UserId, 7) ...
6
3203
by: fniles | last post by:
I am using VB.NET 2005 and Access database. My program uses a timer that kicks in every 1 min to read from a database and copy the dataset table to a datatable. This database is in a class called clsStat.vb. Then I pass this class to a thread. Each thread will call a function inside the clsStat.vb to do a "Select" of the datatable. Every day around the same time this function that does the select of the databale gets errors like so:...
0
10136
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
9988
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
9923
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,...
1
7358
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...
0
5266
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3911
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
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.