ASP查询SQL字段数据

来源:百度知道 编辑:UC知道 时间:2024/05/18 10:39:31
在ASP查询SQL数据库数据的结果中,查询出字段的数据太长;如:ASP查询SQL字段数据;如何让它不换行,或者就固定显示前面几个文字。

<%
if len(rs("name"))<22 then
response.Write(rs("name"))
else
response.Write(left(rs("name"),20)&"...")
end if
%>

function showleft(thetext,howlong)
thetext=trim(thetext)
howlong=clng(howlong)
if len(thetext)>howlong then
showleft=left(thetext,howlong)&"..."
else
showleft=thetext
end if
end function

调用的时候<%= showleft(字段,文字个数) %>

用left函数就可以啦~