Ask a Question related to ASP.NET General, Design and Development.
-
N. Okan Guney #1
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;
}
N. Okan Guney Guest
-
Reading XML into a DataSet
Ok, I posted this before, but I'm going to restate my question in order to hopefully make it clearer. I have the following XML: <?xml... -
How to set cell background based on cell value when datagrid is displayed
I would like to check a datagrid cell value, and change the color of the cell background, when a datagrid is displayed. I want to do this as early... -
I need to have a tooltip appear over a cell showing data from another cell in the same row.
I have a datagrid with locations from around the world. In hidden cells, I have the Lat and Long of that location. I need to be able to mouseover... -
RadioButtonList In A DataGrid Cell - Can I find the selected button without editing the cell?
I have an ASP.NET form with a DataGrid and Button. I want to put a RadioButtonList in a DataGrid cell. I bind it to an ArrayList which has a... -
update row with null numeric or datetime dataset cell values in a datagrid
I keep getting the, now, dreaded "System.FormatException: String was not recognized as a valid DateTime" error when updating a datagrid row that has... -
S. Justin Gengo #2
Re: reading just one cell out of a dataset.
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" <guneyn74@yahoo.com> wrote in message
news:%23P$U5vkSDHA.1912@TK2MSFTNGP12.phx.gbl...using>
> 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> 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;
> }
>
>
S. Justin Gengo Guest
-
Jeff Ptak #3
reading just one cell out of a dataset.
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
could I do this using>-----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. Howtrusted_connection=true;>C#?
>
>Thanks in advance,
>
>
>
>System.Data.DataSet onhand(string partno) {
>
>string connectionString = "server=\'sql01\';[inmast] WHERE>database=\'data03\'";
>
>System.Data.IDbConnection dbConnection = new
>System.Data.SqlClient.SqlConnection(connectionStr ing);
>
>string queryString = "SELECT [inmast].[fonhand] FROM[fcstscode] =>(([inmast].[fpartno] = \'"+partno+"\') AND" + " ([inmast].System.Data.SqlClient.SqlCommand();>\'A\'))";
>
>System.Data.IDbCommand dbCommand = new= dbConnection;>
>dbCommand.CommandText = queryString; dbCommand.ConnectionSystem.Data.DataSet dataSet = new>
>System.Data.IDbDataAdapter dataAdapter = new
>System.Data.SqlClient.SqlDataAdapter();
>
>dataAdapter.SelectCommand = dbCommand;>System.Data.DataSet();
>dataAdapter.Fill(dataSet);
>return dataSet;
>}
>
>
>.
>Jeff Ptak Guest



Reply With Quote

