如何将表中一列数据循环放到一个text控件数组上

qio123 2009-03-04 01:46:50
如何将表中一列数据循环放到一个text控件数组上
...全文
79 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
limpid_123 2009-03-04
  • 打赏
  • 举报
回复
拿分走人
shulei521 2009-03-04
  • 打赏
  • 举报
回复
private void Form1_Load(object sender, EventArgs e)
{
int i = 0;
string sqlconstr = "Data Source=.;Initial Catalog=Northwind; integrated security=SSPI";

using (SqlConnection sqlcon = new SqlConnection(sqlconstr))
{
sqlcon.Open();

string cmdText = "select CategoryID from Categories";
SqlCommand cmd = new SqlCommand(cmdText, sqlcon);
SqlDataReader dr = cmd.ExecuteReader();

while (dr.Read())
{
string[] text=new string[14];
text[++i] = dr.GetInt32(0).ToString();

}
dr.Close();
}
}
睡神在睡觉 2009-03-04
  • 打赏
  • 举报
回复
string[] str=……;
for(int i=0;i<n;i++)
{
textBox1.Text+=str[i];
}
whowhen21 2009-03-04
  • 打赏
  • 举报
回复
循环读取数据的同时,再循环要添加数据的TextBox,然后添加进去。
就是 textBox1.Text = 读取的数据

循环便利控件!
shmily851206 2009-03-04
  • 打赏
  • 举报
回复
不好放 帮顶吧

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧