473,770 Members | 5,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

query against DataRow - DataTable

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

New York New York City
Fishkill
Watertown

this is how it currenlty looks;
State City
Delaware Dover
Delaware Wilimington
Delaware New Castle
New York New York City
New York Fishkill
New York Watertown


foreach (System.Data.Da taTable dt in ds.Tables )
{
foreach ( DataRow row in dt.Rows )
{
count++;
currentCell = (Excel.Range)ce llRangeDetails. Cells[location, i+1];
currentCell.Val ue2 = row[""Car_Make].ToString();
currentCell.Hor izontalAlignmen t = Excel.XlVAlign. xlVAlignJustify ;
location+= 1;
}
}

Nov 17 '05 #1
1 2385
yes ,it is possible to run a SELECT statement against a datatable
For querying data in a DataTable,
you have
DataTable.Selec t //this is not a sql command.
DataTable.Rows. Find

"microsoft.news .com" wrote:
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

New York New York City
Fishkill
Watertown

this is how it currenlty looks;
State City
Delaware Dover
Delaware Wilimington
Delaware New Castle
New York New York City
New York Fishkill
New York Watertown


foreach (System.Data.Da taTable dt in ds.Tables )
{
foreach ( DataRow row in dt.Rows )
{
count++;
currentCell = (Excel.Range)ce llRangeDetails. Cells[location, i+1];
currentCell.Val ue2 = row[""Car_Make].ToString();
currentCell.Hor izontalAlignmen t = Excel.XlVAlign. xlVAlignJustify ;
location+= 1;
}
}

Nov 17 '05 #2

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

Similar topics

2
4846
by: Andrew Mueller | last post by:
Hello, Since I cannot query a DataSet directly, and I would like to maintain it's data, how would I use an adapter (SqlDataAdapter or DataAdapter) to query this DataSet. Example: Could I? SqlDataAdapter adapter = new SqlDataAdapter();
6
4314
by: goodstart123 | last post by:
For example, the following code works fine without SqlConnection. Any Answer to the question? string connectionString = "server=YourServer; uid=sa; pwd=YourPassword; database=ProgASPDotNetBugs"; // get records from the Bugs table string commandString = "Select BugID, Description from Bugs";
4
2936
by: Jim in Arizona | last post by:
Continuing my lessons out of a book, I ran into a problem when trying for the first time to update a datastore (access database in this case). My Code: Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim strConnection, strSQL As String Dim objDataSet As New DataSet() Dim objConnection As OleDbConnection
5
12378
by: Terry Olsen | last post by:
I have an in-memory DataTable with about 35,000 rows. I have an IP address column that is populated and a hostname column that is not. I want to be able to quickly update the hostname column so that it shows the hostname for the IP. Rather than iterate through all the rows, I'm wondering if there's a way to update it quickly with an SQL update command? Something like... UPDATE MyDT SET hostname='localhost' WHERE IP='127.0.0.1' Can...
8
3007
by: Jim in Arizona | last post by:
I've been using an example out of a book to be able to edit the rows in a database. I am getting the following error: ======================================================== ======================================================== Server Error in '/' Application. -------------------------------------------------------------------------------- Operation must use an updateable query. Description: An unhandled exception occurred during...
5
11694
by: samoore33 | last post by:
I use the code below to search through a DataSet: Dim t As DataTable t = result.Tables("State") Dim strExpr As String strExpr = "id = '" & theState.ToString() & "'" Dim foundRows() As DataRow foundRows = t.Select(strExpr) This of course returns foundRows. My problem is that I need to return
6
28328
by: Pete Wittig | last post by:
Hi, I have a DataTable and I want to get a subset of the rows within it. I use the Select method to get my subset and the results are in a DataRow. I want to put those Rows back into a DataTable. I've tried a few variations of the following but no rows are every imported into the datatable: DataRow datrow = ds.Tables.Select("PersonID = " + id); DataTable dt = new DataTable();
2
17653
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
How can I run this query against a table in my Access database? I don't know hwo to use it in C#. In VB I would use .Recordset = "some sql statement". How do I do this in C#? //I get a vlaue form a cell and apply it to the SQL statement commandCol = scriptDataGridView.FormattedValue.ToString(); string sCommand = "SELECT CommandString FROM Commands WHERE CommandName = " + commandCol; //This reutne a valie SQL statement which will return...
3
2100
by: Oenone | last post by:
I have a project that creates a SqlDataAdapter and uses its Fill method to fill a DataTable with data from a user-provided query. From there I can obviously access details about the rows and columns returned by the query. However, I need to be able to determine the size of the varchar fields that are returned by the query. The obvious answer appeared to be to check the DataColumn.MaxLength property. However, after using the Fill method,...
0
9591
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
9425
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
10225
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
10053
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...
0
9867
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...
1
7415
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
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
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.