读书人

再解决不了就疯了高手献身吧~解决

发布时间: 2012-02-07 17:45:36 作者: rapoo

再解决不了,就疯了,高手献身吧~~
<!-- #Include File = "../DbConn.asp " -->
<title> 保存文档 </title>
<%
Dim c_id,S,StrTime_Name,real_id
Randomize Timer
S = Int((8999) * Rnd + 1000)
Str = Asc(Hex(S))

Print_DateTime = Now()
Time_Name = MakeFileName(Print_DateTime)
real_id = "a " & Time_Name & Str

c_id = Cint(Request.Form( "Select_cid "))
'response.write c_id
Article_Title = Request( "Article_Title ")
Doc_Content = trim(Request.form( "cnWords "))
Doc_Content = Replace(Doc_Content, " <script ", " <sscript ")
Doc_Content = Replace(Doc_Content, "/script> ", "/scripts> ")
Doc_Content = Replace(Doc_Content, "/script > ", "/scripts> ")
RealLink = Request( "RealLink ")
'Href_Add = "Content.asp?id=& real_id
Href_Add = "Content.asp?id= "& real_id
AddUser = "anhaiyong "
AddTime =now()
Call Add_Content
Function Add_Content

'----------- 最主要的问题好像在这儿
Call Find_UpClass()
Call Find_ThisClass()
Call Open_Conn()

'----------- 最主要的问题好像在这儿
Sql2= "Insert into ContentTable(p_id,p_name,c_id,c_name,Article_Title,Article_Content,Href_Add,Add_User,AddTime,RealLink,real_id) values( ' "& Rs1( "id ") & " ', ' "& Rs1( "menuname ") & " ', "& Rs3( "id ") & ", ' "& Rs3( "menuname ") & " ', ' "& Article_Title & " ', '123 ', ' "& Href_Add & " ', ' "& AddUser & " ', ' "& AddTime & " ', ' "& RealLink & " ', ' "& real_id & " ') "
Response.write Sql2
Set Rs2 = Server.CreateObject( "ADODB.Recordset ")
Rs2.Open Sql2,Conn,1,1
Response.Write( " <script language= 'javascript '> var Ys = confirm( ' 用户提示:\n\n 用户增加成功,是不继续添加?!单击“确定”继续添加。单击“取消”停止添加。\n\n ');if(Ys){this.location.href= 'index.asp ';}else{window.close();} </script> ")
End Function
Function Find_UpClass()


Call Open_Conn()
Sql1= "Select id,menuname From Menu_Unlimited a Where exists(Select * From Menu_Unlimited b Where b.p_id = a.id and b.id = ' "& c_id & " ') "
response.write Sql1
Set Rs1=server.CreateObject( "adodb.recordset ")
Rs1.open sql1,Conn,1,1
End Function
Function Find_ThisClass()
Call Open_Conn()
Sql3= "Select id,menuname From Menu_Unlimited Where id = " & c_id
response.write Sql3
Set Rs3=server.CreateObject( "adodb.recordset ")
Rs3.open sql3,Conn,1,1
End Function
Function MakeFileName(FName)
FName = Replace(FName, "- ", " ")
FName = Replace(FName, " ", " ")
FName = Replace(FName, ": ", " ")
FName = Replace(FName, "PM ", " ")
FName = Replace(FName, "AM ", " ")
FName = Replace(FName, "上午 ", " ")
FName = Replace(FName, "下午 ", " ")
'FName = right(FName,6)
MakeFileName = FName
End Function
%>

上面的代码实现把指定记录插入到数据库中,但是现在出现的问题是运行的时侯就会提示错误“类型不匹配: 'Rs1 '”,其实去掉 'Rs1 '后, 'Rs3 '也会报这个错,不知写法错在哪里,我认为是由于调用 'Rs1( "id "), 'Rs1(menuname) '时其没有结果也就是调用不成功才会出这个提示,不知是不是,高手帮忙看一下吧

[解决办法]
呵呵,你可以把要的数据读出来,然后交给变量,然后关闭
还有个方法,就是你把数据集名称设成变量,每次调用时设参数,这样就不会重复
当你在一个页面中多次打开一个数据集名,并且重来不关闭,结果还不报错,这样的情况我倒是没有遇到过
[解决办法]
很乱,数据库提议在一开始打开,最后关闭。,因为你这个不是dao class没有方法单独调用的情况,所以不要在方法体内打开数据库链接,消耗资源。建议把查询的返回值放到数组或者对象中在方法体中要关闭是用完的数据集对象,并销毁。
如:
set content=new Content
content.title=rs(0)
content.author=rs(1)
function_name=content

读书人网 >ASP

热点推荐