how can i get a value from my database table and display in a textbox or in the label...

using c#(window application and web application)

kindly guide me

Recommended Answers

All 2 Replies

There's more than one way to do it, and there are questions that have to be answered first. What kind of database is it? Do you already have a connection? Are you running a stored procedure or an ad hoc query? Does the query need any input? Are you doing any other work? The process may need to be run as a transaction.

And more importantly, what have you tried already that didn't work?

this is wat i av done...

what i need is...

i want my username and the region to be fetched from the table and display in every page..
i have done this in web application...

hope tht u can get me de code..

i have done this with MY-SQL
con=new SqlConnection("server=pstlcorpserv;database=mis;user Id=sa;password=sqlserver12#");
adap = new SqlDataAdapter("select region from users where username like @r", con);
set = new DataSet();
adap.SelectCommand.Parameters.Add("@r", SqlDbType.VarChar);
adap.SelectCommand.Parameters[0].Value = Label2.Text+"%";
adap.Fill(set, "users").ToString();
Label2.Text = set.Tables[0].Columns.ToString();

Be a part of the DaniWeb community

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