473,378 Members | 1,404 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,378 software developers and data experts.

C# : how to get a value from a dataset?

RD
clsConnect ObjConnect = new clsConnect();

string ConnectionString=ObjConnect.Connstring;

SqlConnection myConn=new SqlConnection(ConnectionString);

SqlCommand myCMD = new SqlCommand("SELECT * from Customer Where CustomerId
= 1",myConn);
SqlDataAdapter myDA = new SqlDataAdapter();

myDA.SelectCommand = myCMD;

myConn.Open();

DataSet myDS = new DataSet();

myDA.Fill(myDS);

----------------------------------------------------------------------------
-

Now I want to get the values of specific fields.
(Lastname,firstname,------------) How can I do that?

Thanks

RD




Nov 15 '05 #1
1 63437
for(int i = 0; i < ds.Tables[0].Rows.Count; i++)

{

ds.Tables[0].Rows[i][0].ToString();// = first name
ds.Tables[0].Rows[i][1].ToString();// = last name
ds.Tables[0].Rows[i][2].ToString();// = ---------
}
for simple values you really should consider using a data reader instead of
a dataset. its faster because there is less overhead

--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"RD" <di******@alltel.net> wrote in message
news:%8*************@fe01.usenetserver.com...
clsConnect ObjConnect = new clsConnect();

string ConnectionString=ObjConnect.Connstring;

SqlConnection myConn=new SqlConnection(ConnectionString);

SqlCommand myCMD = new SqlCommand("SELECT * from Customer Where CustomerId = 1",myConn);
SqlDataAdapter myDA = new SqlDataAdapter();

myDA.SelectCommand = myCMD;

myConn.Open();

DataSet myDS = new DataSet();

myDA.Fill(myDS);

-------------------------------------------------------------------------- -- -

Now I want to get the values of specific fields.
(Lastname,firstname,------------) How can I do that?

Thanks

RD




Nov 15 '05 #2

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

Similar topics

5
by: DraguVaso | last post by:
Hi, Something I don't understand about a Typed DataSet: When a value in the DataSet is DBNull, it throws this error: "Cannot get value because it is DBNull". But aren't Typed DataSets...
8
by: drg | last post by:
I have a DataSet with a DateTime field. I am using an EventRow r, to update it with values from a TextBox in a DataGrid. Suppose a DataGrid in edit mode had a field with value: 7/7/2005. Then the...
3
by: Jason Huang | last post by:
Hi, How to we tell if a DataSet is null in a ASP.Net C# Windows Form? Is it possible that a DataSet is not null but has no DataTable? What will be the simplest code? Thanks for help. Jason
12
by: Graham Blandford | last post by:
Hi all, Would someone be able to tell me the most 'graceful' way of removing unwanted rows from a dataset based on a condition prior to update? OR, resetting the rows all to unchanged after they...
4
by: pmcguire | last post by:
I have designed a user control (UserControl0) from which several other user controls (ChildUserControl(n)) inherit. Each ChildUserControl(n) has its own strongly typed dataset. I would like to...
5
by: needin4mation | last post by:
Hi, I have a webservice that just returns a count: public DataSet HelloWorld() { OdbcConnection conn = new OdbcConnection("DSN=xxx"); String sqlString = "select count(*) as employee from...
0
by: BVA3105 | last post by:
i update a database with a dataset and a SqlAdapter with success but when i clear and refill my dataset i always retreive the old values. I have to wait for 5 seconds to get the corrects values. ...
0
by: rickbear | last post by:
Hi group... I am having big difficulties with dataset and xsd schemas. First I dedicate a specific schema to a dataset. Then I use an adapter to fill each table in the dataset. But the problem...
0
by: =?Utf-8?B?TGFzdGJ1aWxkZXJz?= | last post by:
Hi all, I have a weird problem which has been causing me a headache for the last two days. I have to dynamicly generate a schema in memory and load it into a dataset in memory to be returned...
4
by: haarigee | last post by:
I need to insert without any parameters and execution query. Since, I have bulk of data's in a dataset the amount of transaction makes the application delay. So i need to directly insert my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.