主题:  高手帮帮忙!

audreys

职务:普通成员
等级:1
金币:0.0
发贴:8
注册:2001/12/4 10:43:34
#12002/1/8 12:49:31
我的数据库里表名:tUsers2
字段为:fUserName, (用户名)fPassword(密码), fGroup(组), fEMai(电子邮件)
文件insert.asp中对应四个type="text"类型表单(表单名分别为:txtname , txtpassword , txtgroup , txtemail)Form到Result.asp页面,希望能用Result.asp页面中command的INSERT来添加内容(四个变量名分别为:Command1__strname 、Command1__strpassword 、Command1__strgroup 、Command1__stremail 、对应四个表单值),代码如下:
<%

if(Request.Form("txtname") <> "") then Command1__strname = Request.Form("txtname")

if(Request.Form("txtpassword") <> "") then Command1__strpassword = Request.Form("txtpassword")

if(Request.Form("txtgroup") <> "") then Command1__strgroup = Request.Form("txtgroup")

if(Request.Form("txtemail") <> "") then Command1__stremail = Request.Form("txtemail")

%>
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_BHP_STRING 'MM_BHP_STRING是UD定义的数据连接位置
Recordset1.Source = "SELECT * FROM tUsers2"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
if(Request.Form("txtUsername") <> "") then
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_BHP_STRING
Command1.CommandText = "INSERT INTO tUsers2 (fUserName, fPassword, fGroup, fEMail) valueS ('" + Replace(Command1__strname, "'", "''") + "','" + Replace(Command1__strpassword, "'", "''") + "','" + Replace(Command1__strgroup, "'", "''") + "','" + Replace(Command1__stremail, "'", "''") + "') "
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
end if
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
可是内容添加不进去,请问各位高手,我错在哪了?该如何改??
Text

编辑历史:[这消息被audreys编辑过(编辑时间2002-01-08 12:53:00)]


audreys

职务:普通成员
等级:1
金币:0.0
发贴:8
注册:2001/12/4 10:43:34
#22002/1/8 16:45:49
简而言之就是如何用command的insert来实现纪录的插入?能不能给个例子!谢谢