<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %><script runat="server">
protected void Page_Load(Object Src, EventArgs E)
{
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+="Data Source=";
strConnection+=MapPath("data\\data.mdb");
OleDbConnection objConnection=new OleDbConnection(strConnection);
OleDbCommand objCommand = new OleDbCommand("select * from 文字 where 位置='index1'" , objConnection);
objConnection.Open();
OleDbDataReader objDataReader=objCommand.ExecuteReader();
if(objDataReader.Read())
{
Label1.Text=Convert.ToString(objDataReader["标题"]);
Label2.Text=Convert.ToString(objDataReader["内容"]); ******我想控制现实字数不超过10个
}
objConnection.Close();
}
</script>
<html>
<head>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %><script runat="server">
protected void Page_Load(Object Src, EventArgs E)
{
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+="Data Source=";
strConnection+=MapPath("data\\data.mdb");
OleDbConnection objConnection=new OleDbConnection(strConnection);
OleDbCommand objCommand = new OleDbCommand("select * from 文字 where 位置='index1'" , objConnection);
objConnection.Open();
OleDbDataReader objDataReader=objCommand.ExecuteReader();
if(objDataReader.Read())
{
Label1.Text=Convert.ToString(objDataReader["标题"]);
Label2.Text=Convert.ToString(objDataReader["内容"]); ******我想控制现实字数不超过10个
}
objConnection.Close();
}
</script>
<html>
<head>
解决方案 »
- 关于asp.net与数据库使用问题
- 为什么我设计的页面无法显示啊???
- 应用程序中的服务器错误
- javascript中,date()函数中使用System.DateTime类型的参数啊
- 急!!Visual Studio2003在Window 2003找不到虚拟目录
- 有没有什么好办法可以将A服务器上生成的xml文件自动传输到异地远程的B服务器上?
- 如何用ASP.NET开发一个智能建站系统?
- 【求教】.net下如何取得客户端计算机的MAC地址?或者其它唯一标识
- 怎么才能知道某个ip在当前页面里停留了多长时间?
- 在.net studio 中编辑的.aspx网页无法显示的问题!急!!!100分相送!
- 各位大哥,过来帮小妹解答一下啊~
- 有谁知道这里该如何写呢? 等~
select id,case when len(title)>22 then(substring(title,0,20)+'...') else title end as title,filltime,pic,name from table
select * from 文字 where 位置='index1'select * wen len(title)>10 then(substring(title,0,10)+'...') else title end as title from '文字' where 位置='index1'
这样对吗?substring(title,0,10)+'...'什么意思?
else title end as title 什么意思??
谢谢大哥
SUBSTRING ( expression , start , length )
expression
是字符串、二进制字符串、text、image、列或包含列的表达式。不要使用包含聚合函数的表达式。start
是一个整数,指定子串的开始位置。length
是一个整数,指定子串的长度(要返回的字符数或字节数)。
符合条件的
else
不符合条件的
end
错误代码:
IErrorInfo.GetDescription failed with E_FAIL(0x80004005).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: IErrorInfo.GetDescription failed with E_FAIL(0x80004005).
我的代码:
for(int i=0;i<=2;i++)
{int tp=i+1;
OleDbCommand objCommand = new OleDbCommand("select *,wen len(title)>10 then(substring(title,0,10)+'...') else title end as title from '文字' where 位置='index'"+ tp +"'" , objConnection);
OleDbDataReader objDataReader=objCommand.ExecuteReader();
if(objDataReader.Read())
{ string lcID="lable"+i*3+1;
Control loCtrl=this.FindControl(lcID);
if (loCtrl!=null&&loCtrl is Label)
{
((Label)loCtrl).Text=Convert.ToString(objDataReader["标题"]);
}
lcID="lable"+i*3+2;
loCtrl=this.FindControl(lcID);
if (loCtrl!=null&&loCtrl is Label)
{
((Label)loCtrl).Text=Convert.ToString(objDataReader["内容"]);
}
} }