asp insert into 问题

来源:百度知道 编辑:UC知道 时间:2024/05/15 14:26:34
数据表结构
id 自动编号
last_name 文本
first_name 文本
sales 货币(注意是”货币“类型)

我写的程序
<%@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>

<%

Dim conn,ConnStr,fname,lname,lsales,i

i =0
fname = request.Form("txtfanme")
lname = request.Form("txtlanme")
lsales = request.Form("txtsales"

strSql = "Insert into sample(last_name,first_name,sales) values('"&lname&"','"&fname&"','"&lsales&"')"
set rs = conn.execute(strSql)

第一行:strSql = "Insert into sample(last_name,first_name,sales) "
第二行:strSql = strSql & "values('"&lname&"','"&fname&"','"&lsales&"')"
注意第一行最后应该有一个空格,或者第二行的开始有一个空格
不然SQL就拼错了

第二行改为strSql = strSql + "values('"&lname&"','"&fname&"','"&lsales&"')"
这样就和strSql = "Insert into sample(last_name,first_name,sales) values('"&lname&"','"&fname&"','"&lsales&"')" 是一样的功能了
随便采取哪种都可以