C#求高手
private void button2_Click(object sender, EventArgs e)
{
String cnno = "Data Source=HP-PC;Initial Catalog=FIRST;Integrated Security=True;Pooling=False";
SqlConnection connection = new SqlConnection(cnno);
string sql1 = string.Format("select * from Qjia where Qno='{0}'", send_str);
connection.Open();
SqlCommand command1 = new SqlCommand(sql1, connection);
SqlDataReader sr1 = command1.ExecuteReader();
while (sr1.Read())
{
textBox2.Text = sr1["Qstart"].ToString() + " 到 " + sr1["Qend"].ToString()+"\n\n";
// textBox2.Text = sr["Xname"].ToString();
}
}
我想把表里的数据都显示出来怎么改呢。。这里只显示了最后一行,新手。。。
------最佳解决方案-------------------- textBox2.Text += sr1["Qstart"].ToString() + " 到 " + sr1["Qend"].ToString()+"\r\n";
------其他解决方案--------------------去掉换行符"\n\n"
------其他解决方案--------------------谢谢啦谢谢啦谢谢啦。。可以了。。