0

Is it possible to load database data into labels for viewing?
i already know the query to return the data i want to show but i dont know how to put it into a label.. anyone got any ideas? i tried searching but so far i have nothing.. :c

4
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by reena12
0

im sorry im kinda new at this, can you expand? thank you very much. :)

0

I don't know whitch kind of data base you use but any way. Fill a dataset object with data using Data Adapter as normally
then

you can get the cell value of a given data table as follow and set it to the textbox.text

textBox.Text = dataset.tables[0].rows[ row index here][cell index here];

0

Hi

SqlConnection ObjConn = new SqlConnection(ConnectionString);


if (ObjConn.State != ConnectionState.Open)
{
ObjConn.Open();
}


SqlDataAdapter ObjSqlDataAdapter = new SqlDataAdapter(CommandText, ObjConn);


Ds = new DataSet();
ObjSqlDataAdapter.Fill(Ds);


if (ObjDs.Tables[0].Rows.Count > 0)
{
label1.Text = ObjDs.Tables[0].Rows[rowindex][columnname].toString();
-
-
}


ObjDs.Dispose();
ObjConn.Close();
ObjConn.Dispose();

Edited by happygeek: fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.