473,385 Members | 2,014 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,385 software developers and data experts.

What adapter to use for DataSet query

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();

adapter.Fill(myDataSet);

adapter.SelectCommand = "Select * from Table where x = '';

foreach (DataRow dr in adapter.rows)
{
//whatever processing I want here...
}
Andrew Mueller
Nov 15 '05 #1
2 4831
Andrew,

You can not do it like this. If the criteria are simple enough, then
you can create a DataView against that DataTable and then set the RowFilter
property on the view to filter out rows that you do not want to process.
You can then cycle through the rows made available to you through the
DataView.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Andrew Mueller" <am******@instechnet.com> wrote in message
news:em****************@TK2MSFTNGP10.phx.gbl...
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();

adapter.Fill(myDataSet);

adapter.SelectCommand = "Select * from Table where x = '';

foreach (DataRow dr in adapter.rows)
{
//whatever processing I want here...
}
Andrew Mueller

Nov 15 '05 #2
Thanks...

Tried that and I am having some problem... Here is my code. {ds = DataSet
with data. The Table is DataSettings and one of the 'columns' is called
Temperature}
DataView dv = new DataView();

dv.Table = ds.Tables["DataSettings"];
if (ds != null)

{
dv.RowFilter = "Temperature = ''";
foreach (DataRow dr in dv.Table.Rows)

{

Debug.WriteLine(dr["MashNumber"]);

return dr["MashNumber"].ToString();

}

}

However, when I run this code, I get an error on the foreach statement that:

An unhandled exception of type 'System.Data.EvaluateException' occurred in
system.data.dll

Additional information: Cannot perform '=' operation on System.Double and
System.String.

Any ideas?
Thanks in advance,

Andrew Mueller

"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:%2****************@tk2msftngp13.phx.gbl...
Andrew,

You can not do it like this. If the criteria are simple enough, then
you can create a DataView against that DataTable and then set the RowFilter property on the view to filter out rows that you do not want to process.
You can then cycle through the rows made available to you through the
DataView.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Andrew Mueller" <am******@instechnet.com> wrote in message
news:em****************@TK2MSFTNGP10.phx.gbl...
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();

adapter.Fill(myDataSet);

adapter.SelectCommand = "Select * from Table where x = '';

foreach (DataRow dr in adapter.rows)
{
//whatever processing I want here...
}
Andrew Mueller


Nov 15 '05 #3

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

Similar topics

1
by: rodney | last post by:
Hey all, I was just wondering why in some examples in loading a dataset I see the data adapter object and then in others I don't see the data adapter object. Thanks, Rodney
0
by: compuglobalhypermeganetz0r | last post by:
I am having trouble getting an adapter to update my access database, it gives the error Syntax error in INSERT INTO statement. for Line 98: Adapter.Update(WineDS, "tblWines") Below is my...
1
by: Andrew | last post by:
All, Apologies if off topic. I'm new to .net, although an experienced programmer, and am working on the client end of a sql application. It holds every single request that goes through our...
1
by: | last post by:
I will be add Data in my Example Database. I have this Code by a ASP.NET Book but this will not work. Error message: Operation must be a actually Query use. Error in:...
3
by: Al Gerharter | last post by:
Hi, I'm building a form, and tying it to a database via SQL connection, SQLdataadapter, and a Dataset. It appears that the data adapter will not let me select more than 100 fields in the SQL...
7
by: GatorBait | last post by:
Hi all, I am having a problem with my data adapter update command. I have generated the data adapter in the IDE and then I built a dataset. The dataset can get changed in the program and I...
3
by: optictygre | last post by:
Hi folks. I have a couple questions about updating data from a dataset to a database using a data adapter. If I declare an adapter, set the batchupdatesize property to 0, and then call the...
16
by: SLIMSHIM | last post by:
Hi, I"m new to c# and .net. I wrote a small program to add rows to an access table. the program goes thru the motions but the data never gets there. here is my code. I am intentionaly not using...
1
by: hadi | last post by:
Hi, When I try to add a query to a Tableadapter in a Typed Dataset , I get this message : "command text returns data with schema different from that of main query". Till this part is ok, but when...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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,...
0
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...

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.