数据集值分配给文本框

编程入门 行业动态 更新时间:2024-10-24 22:26:38
本文介绍了数据集值分配给文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

以下是我项目的代码... 请告诉我如何从数据集中获取值并显示到文本框,

following is the code of my project... please tell me how to get values from dataset and show to textboxes ,

SqlConnection cn = new SqlConnection("Data Source=SomePC\\SQLEXPRESS;Initial Catalog=SomeDB;Integrated Security=True;"); da = new SqlDataAdapter("select * from clubAC where accountno=" + txtacno .Text + "", cn); ds = new DataSet(); cn.Open(); da.Fill(ds, "clubAC");

我想展示... textbox1.text = ..........来自数据集的值.

i want to show... textbox1.text=..........value from dataset.

推荐答案

TextBox1.Text=ds.Tables[0].Rows[0][0].ToString();

希望对您有所帮助.

Hope this can help you.

textbox1.text = Dataset.Tables[0].Rows[0][0].ToString();

供您参考 在C#.NET中显示数据集中的数据 [ ^ ]

For your information Display Data from a Dataset in C# .NET[^]

您不能这样做.您可以将1列显示在textbox1.Text下. 如果要显示textbox1.Text下所有列的所有值,则必须将所有值合并为一个字符串值. You cannot do that. You can take 1 column and show it under textbox1.Text. If you want to show all values from all columns under your textbox1.Text, you have to concat all values to one string value.

更多推荐

数据集值分配给文本框

本文发布于:2023-11-10 00:41:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573893.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本框   数据   集值分

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!