SqlDataReader reader = null;
SqlConnection cn = new SqlConnection(global::vaja15.Properties.Settings.Default.Database1ConnectionString);
cn.Open();
SqlCommand sda = new SqlCommand("SELECT * FROM Uporabnik WHERE attacktype='melee' ", cn);
reader = sda.ExecuteReader();
while (reader.Read())
{
richTextBox1.Text = reader[4].ToString();
}
cn.Close();
How can I select every row that is in the database like melee?
You will have to dynamically add new TextBox or Label for each iteration of the while loop if you want this to work:
while (reader.Read())
{
TextBox dynamicTextbox = new TextBox();
Panel1.Controls.Add(dynamicTextbox );
dynamicTextbox.Text = reader[4].ToString();
}
Note I am assuming you are using a Panel to group the textboxes together.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.