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

Recommended Answers

All 4 Replies

Work through the returned data setting the appropriate labels

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

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];

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();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.