【asp+数据库】如何把字符"1+2" 让它等于3?
2008-10-25 10:45
295 查看
数据库代码如下:
---------------------
create database test
use test
create table test_gongshi
(
name varchar(100),--标记
x varchar(1000),--x
y varchar(1000),--y
z varchar(1000),--z
n varchar(1000),--n
)
insert into test_gongshi values('门边','a+b','b+c','c+d','0')
select * from test_gongshi
---------------------
---------------------
页面代码如下:
---------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%
set conn=server.CreateObject("adodb.connection")
str="Driver={SQL Server};server=(local);uid=qi;pwd=13940282230;database=test"
conn.open(str)
sql="select * from test_gongshi"
set rs=conn.execute(sql)
a=1
b=2
c=3
d=4
gongshi=replace(rs("x"),"a",a)'注:此处 rs("x")=a+b
gongshi=replace(gongshi,"b",b)
response.Write(gongshi)
'response.Write(rs("x"))
response.Write("<br>")
gongshi2=replace(rs("y"),"b",b)
gongshi2=replace(gongshi2,"c",c)
response.Write(gongshi2)
%>
</body>
</html>
-------------------------
问题就在于公式能拿出来~,但最后的结果不是数字,这个问题如何解决?
---------------------
create database test
use test
create table test_gongshi
(
name varchar(100),--标记
x varchar(1000),--x
y varchar(1000),--y
z varchar(1000),--z
n varchar(1000),--n
)
insert into test_gongshi values('门边','a+b','b+c','c+d','0')
select * from test_gongshi
---------------------
---------------------
页面代码如下:
---------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%
set conn=server.CreateObject("adodb.connection")
str="Driver={SQL Server};server=(local);uid=qi;pwd=13940282230;database=test"
conn.open(str)
sql="select * from test_gongshi"
set rs=conn.execute(sql)
a=1
b=2
c=3
d=4
gongshi=replace(rs("x"),"a",a)'注:此处 rs("x")=a+b
gongshi=replace(gongshi,"b",b)
response.Write(gongshi)
'response.Write(rs("x"))
response.Write("<br>")
gongshi2=replace(rs("y"),"b",b)
gongshi2=replace(gongshi2,"c",c)
response.Write(gongshi2)
%>
</body>
</html>
-------------------------
问题就在于公式能拿出来~,但最后的结果不是数字,这个问题如何解决?
相关文章推荐
- 【asp+数据库】如何把字符"1+2" 让它等于3?以及解决办法
- 数据库中的某字段的值像(4,5,6,9,15),查询出包含字符"5"的记录,像(6,9,15)这样的不算
- 如何连接判断字符新方法,如:where id0 and username="" and ......2006-6-8-3
- 如何修复SQLSERVER 数据库"置疑"之(二)
- (注意)如何判断数据库字段 不为空 不为null 不为" "
- 如何理解">/dev/null 2>&1"
- [SQL Server] 如何查询windows认证的用户连接数据库时的"权限/对应的登陆账号"(该账号是一个windows组)
- python如何提取某一个固定的字符之间的数据如<img src= >" 内容"
- 数据库字段内容存在'、"、>、<等特殊字符,转义html字符输出
- 如何处理Oledb中EXCEL驱动读取EXCEL文件中字段长度大于255字符时出现的"数据截断"问题.
- [求教] - 关于ASP中如何对数据表字段中所包含的特殊字符 ' 与 " 进行转义处理?
- 如何解决如"未能加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或
- 解决vs2010“创建或打开C++浏览数据库文件 发生错误”的问题"
- "请备份该数据库的事务日志以释放一些日志空间"解决方法
- 如何将sql server 数据库表中的某一列的某一字符替换成需要的字符
- 如何给"包"添加Javadoc注释
- 转载:html特殊字符 编码css3 content:&quot;我是特殊符号&quot;
- 正则特殊字符后台与前台页面2种方式content = content.Replace("/\r\n/g", ""); content = content.Replace
- 两个数据库间的"复制"
- 如何取得刚插入数据库的数据的id m…