how can i pass a database value to a textbox if i click a button.. should i use a query statement..? what kind? help pls ...

Recommended Answers

Set up your connection to the database and a command object with your SQL statement in it. Execute the command on the database, storing the result in a string, and then set the text box.text to the extracted value. So, pseudo code (assuming mySql):

MySqlConnection conn = …
Jump to Post

All 2 Replies

Set up your connection to the database and a command object with your SQL statement in it. Execute the command on the database, storing the result in a string, and then set the text box.text to the extracted value. So, pseudo code (assuming mySql):

MySqlConnection conn = new MySqlConnection(/connection string/);
MySqlCommand cmd = new mySqlCommand();
cmd.Connection = conn;
cmd.CommandText = your sql statement
conn.Open()
MySqlDataReader dr = cmd.executeReader();
conn.Close();
if(dr.hasRows) {
while(dr.Read()) {
    textbox.text = dr.getString(0);
}
}

And that should do it for you.

thanks for the help.. i will try that :D

Be a part of the DaniWeb community

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