我如何从asp.net中的sqlserver获取子字符串? [英] How can i get sub string from sqlserver in asp.net?
本文介绍了我如何从asp.net中的sqlserver获取子字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我的数据库表列中有长文本..我只想检索50个字符...我该怎么做..请帮助我提供示例代码或链接..
谢谢..
Hi to All,
I have long text in my database table column.. i want to retrieve only 50 characters... how can i do this one.. please help me with sample code or links..
Thank you..
推荐答案
select Cast(column as varchar(50))from table1
简单,首先将完整的字符串检索到变量中.净额.
写下面的代码:
string stringVariable =在这里从数据库获取值";
string stringValue = stringVariable.Substring(0,50)//仅返回50个值.
stringValue具有所需的50个长度.
simple first retrieve complete string into a variable in .net.
The write the below code:
string stringVariable = "get the values from database here";
string stringValue = stringVariable.Substring(0,50) // this returns only 50 values.
stringValue haves the required 50 length.
这篇关于我如何从asp.net中的sqlserver获取子字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文