如何在sql中使用select命令? [英] How to use the select command in sql?
本文介绍了如何在sql中使用select命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
我有一个包含id,lastname,firstname和middlename字段的表。现在,我需要在一个文本框中显示id匹配的全名。任何人都可以帮助我吗?
Hi guys!
I have a table that consist fields of id,lastname, firstname and the middlename. Now, I need to display in one textbox the fullname where the id matches. Can Anyone help me out?
推荐答案
有很多关于CP数据访问的文章,这是我的一篇:
通过ADO.NET接口进行简化数据库访问 [ ^ ]
There are many articles about data access on CP, here's one of mine:
Simplified Database Access via ADO.NET Interfaces[^]
SqlCommand query = new SqlCommand("SELECT lastname, firstname, middlename FROM tblStudent WHERE fldID='" + txtSearch.Text + "'", amicassaCon);
SqlDataReader dr = query.ExecuteReader();
while (dr.Read())
{
string a = dr[1].ToString();
string b = dr[2].ToString();
string c= dr[3].ToString();
txtName.Text = a + ',' + b + ' ' + c;
dr.Close();
SELECT ISNULL(firstname,'')+''+ ISNULL(middlename,'')+''+ ISNULL(lastname,' ')FROM Tblusers
SELECT ISNULL(firstname,'') +' '+ ISNULL(middlename,'') + ' ' + ISNULL(lastname,'') FROM Tblusers
这篇关于如何在sql中使用select命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文