473,503 Members | 11,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reading just one cell out of a dataset.


Hello,
How could I read just one cell out of a dataset?

I have a query returing a 3 x 3 table.

a b c
d e f
x y z
I need the value of "f" ([2][2] ) from the table. How could I do this using
C#?

Thanks in advance,

System.Data.DataSet onhand(string partno) {

string connectionString = "server=\'sql01\'; trusted_connection=true;
database=\'data03\'";

System.Data.IDbConnection dbConnection = new
System.Data.SqlClient.SqlConnection(connectionStri ng);

string queryString = "SELECT [inmast].[fonhand] FROM [inmast] WHERE
(([inmast].[fpartno] = \'"+partno+"\') AND" + " ([inmast].[fcstscode] =
\'A\'))";

System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand();

dbCommand.CommandText = queryString; dbCommand.Connection = dbConnection;

System.Data.IDbDataAdapter dataAdapter = new
System.Data.SqlClient.SqlDataAdapter();

dataAdapter.SelectCommand = dbCommand; System.Data.DataSet dataSet = new
System.Data.DataSet();
dataAdapter.Fill(dataSet);
return dataSet;
}
Nov 17 '05 #1
4 18276
DataSet.Tables("TableName").Rows(1)(2)

Where Rows(Zero Based Row Number Index)(Zero Based Column Index)

Or Rows(1)("ColumnNameAsString")

Hope this helps.

Justin
"N. Okan Guney" <gu******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...

Hello,
How could I read just one cell out of a dataset?

I have a query returing a 3 x 3 table.

a b c
d e f
x y z
I need the value of "f" ([2][2] ) from the table. How could I do this using C#?

Thanks in advance,

System.Data.DataSet onhand(string partno) {

string connectionString = "server=\'sql01\'; trusted_connection=true;
database=\'data03\'";

System.Data.IDbConnection dbConnection = new
System.Data.SqlClient.SqlConnection(connectionStri ng);

string queryString = "SELECT [inmast].[fonhand] FROM [inmast] WHERE
(([inmast].[fpartno] = \'"+partno+"\') AND" + " ([inmast].[fcstscode] =
\'A\'))";

System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand();

dbCommand.CommandText = queryString; dbCommand.Connection = dbConnection;

System.Data.IDbDataAdapter dataAdapter = new
System.Data.SqlClient.SqlDataAdapter();

dataAdapter.SelectCommand = dbCommand; System.Data.DataSet dataSet = new
System.Data.DataSet();
dataAdapter.Fill(dataSet);
return dataSet;
}

Nov 17 '05 #2
DataSet.Tables("TableName").Rows(1)(2)

Where Rows(Zero Based Row Number Index)(Zero Based Column Index)

Or Rows(1)("ColumnNameAsString")

Hope this helps.

Justin
"N. Okan Guney" <gu******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...

Hello,
How could I read just one cell out of a dataset?

I have a query returing a 3 x 3 table.

a b c
d e f
x y z
I need the value of "f" ([2][2] ) from the table. How could I do this using C#?

Thanks in advance,

System.Data.DataSet onhand(string partno) {

string connectionString = "server=\'sql01\'; trusted_connection=true;
database=\'data03\'";

System.Data.IDbConnection dbConnection = new
System.Data.SqlClient.SqlConnection(connectionStri ng);

string queryString = "SELECT [inmast].[fonhand] FROM [inmast] WHERE
(([inmast].[fpartno] = \'"+partno+"\') AND" + " ([inmast].[fcstscode] =
\'A\'))";

System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand();

dbCommand.CommandText = queryString; dbCommand.Connection = dbConnection;

System.Data.IDbDataAdapter dataAdapter = new
System.Data.SqlClient.SqlDataAdapter();

dataAdapter.SelectCommand = dbCommand; System.Data.DataSet dataSet = new
System.Data.DataSet();
dataAdapter.Fill(dataSet);
return dataSet;
}

Nov 17 '05 #3
Try this:

F_Value = dataset.Tables[0].Rows[1].ItemArray[5];

Or

F_Value = dataset.Tables[0].Rows[1]["FieldNameForF"];

You may have to cast the value to the correct datatype,
but this should get you started.

HTH,

Jeff Ptak

-----Original Message-----

Hello,
How could I read just one cell out of a dataset?

I have a query returing a 3 x 3 table.

a b c
d e f
x y z
I need the value of "f" ([2][2] ) from the table. How could I do this usingC#?

Thanks in advance,

System.Data.DataSet onhand(string partno) {

string connectionString = "server=\'sql01\'; trusted_connection=true;database=\'data03\'";

System.Data.IDbConnection dbConnection = new
System.Data.SqlClient.SqlConnection(connectionStr ing);

string queryString = "SELECT [inmast].[fonhand] FROM [inmast] WHERE(([inmast].[fpartno] = \'"+partno+"\') AND" + " ([inmast]. [fcstscode] =\'A\'))";

System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand();
dbCommand.CommandText = queryString; dbCommand.Connection = dbConnection;
System.Data.IDbDataAdapter dataAdapter = new
System.Data.SqlClient.SqlDataAdapter();

dataAdapter.SelectCommand = dbCommand; System.Data.DataSet dataSet = newSystem.Data.DataSet();
dataAdapter.Fill(dataSet);
return dataSet;
}
.

Nov 17 '05 #4
Try this:

F_Value = dataset.Tables[0].Rows[1].ItemArray[5];

Or

F_Value = dataset.Tables[0].Rows[1]["FieldNameForF"];

You may have to cast the value to the correct datatype,
but this should get you started.

HTH,

Jeff Ptak

-----Original Message-----

Hello,
How could I read just one cell out of a dataset?

I have a query returing a 3 x 3 table.

a b c
d e f
x y z
I need the value of "f" ([2][2] ) from the table. How could I do this usingC#?

Thanks in advance,

System.Data.DataSet onhand(string partno) {

string connectionString = "server=\'sql01\'; trusted_connection=true;database=\'data03\'";

System.Data.IDbConnection dbConnection = new
System.Data.SqlClient.SqlConnection(connectionStr ing);

string queryString = "SELECT [inmast].[fonhand] FROM [inmast] WHERE(([inmast].[fpartno] = \'"+partno+"\') AND" + " ([inmast]. [fcstscode] =\'A\'))";

System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand();
dbCommand.CommandText = queryString; dbCommand.Connection = dbConnection;
System.Data.IDbDataAdapter dataAdapter = new
System.Data.SqlClient.SqlDataAdapter();

dataAdapter.SelectCommand = dbCommand; System.Data.DataSet dataSet = newSystem.Data.DataSet();
dataAdapter.Fill(dataSet);
return dataSet;
}
.

Nov 17 '05 #5

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

Similar topics

4
2818
by: Steve B. | last post by:
I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's reflect the contents of the grid cells. Sorting of columns (both thru VS and programmatically) work fine except, when the...
0
948
by: N. Okan Guney | last post by:
Hello, How could I read just one cell out of a dataset? I have a query returing a 3 x 3 table. a b c d e f x y z
1
3527
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say...
5
1317
by: WebBuilder451 | last post by:
is there ant place where i can learn the basics of reading an rss feed and enumerating through the values? just want to start at the bottom, no frills. thanks -- thanks (as always) some day...
4
10684
by: Roger | last post by:
I have a datagrid and would like to know what even fires when a cell is changed? I want to know when the user changes a cell and moves to the next. I have some code that needs to be done to...
0
1289
by: theintrepidfox | last post by:
Dear Group I really need your help on this issue. I've a datagrid which source is a dataview based on a dataset. The columns of the grid are datagridtextbox columns created like the following...
5
8925
by: Scott M. Lyon | last post by:
I've just discovered a bug in some code I wrote a little while ago, and I need you guys' help to fix it. My program imports data from a standard Excel Spreadsheet (just with specific column...
2
5603
by: rwiegel | last post by:
I'm trying to read rows from an Excel file and display them in an ASP.NET DataGridview. I am using C# for the code file. I am using OleDb to read from the Excel file. The columns that contain...
1
4435
by: Drake250 | last post by:
I've been trying to play around with reading in an XML file that would look something like this into a 2D array with no luck: <?xml version="1.0" ?> <map index="0" name="Test" cellsx="2" cellsy="2"...
0
7095
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
7361
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...
1
7015
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...
0
7470
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...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
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 ...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
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...

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.