在文本框中显示sql搜索结果 [英] show sql search result in textboxes
本文介绍了在文本框中显示sql搜索结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在几个文本框中显示sql serach结果(例如我的serach有4个记录,每个记录有5个fiels我想在一个文本框中显示一个字段)
解决方案
< blockquote>这很容易做到。如果你有一个SQL帮助程序类使用它,你可以使用SqlCommand对象和SqlDataReader以及SqlConnection。
类似于:
dr = cmd.ExecutReader();
if (dr.HasRows)
{
dr.Read();
textbox1.Text = dr [ FirstField]。ToString();
textbox2.Text = dr [ SecondField]。ToString();
}
等等。
i want show sql serach result in several textboxes(for example my serach have 4 record and every record have 5 fiels i want show one field in one textbox)
解决方案
This is easy to do. If you have a SQL helper class use that or you can use the SqlCommand object and the SqlDataReader along with the SqlConnection.
Something similar to:
dr = cmd.ExecutReader(); if (dr.HasRows) { dr.Read(); textbox1.Text = dr["FirstField"].ToString(); textbox2.Text = dr["SecondField"].ToString(); }
so on and so forth.
这篇关于在文本框中显示sql搜索结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文