亲爱的所有专业程序员,我在这里是全新的,我可能不知道如何正确地作为一个问题在这里..
如果我可以寻求帮助,你能不能在这里...我遇到了带有 oop 结构的简单 asp 的问题...
请帮我保存数据功能。运行时,
call savedata("insert","test_","name, id","lalala, 222","User_ID=3")
得到错误:
INSERT INTO test_ (name, id) VALUES (lalala, 222)
... Microsoft VBScript 运行时错误“800a01a8”
所需对象:'Conn'
<%
function declare_conn(sql,atr)
dim conn, conn_
set conn = Server.CreateObject("ADODB.Connection")
conn = Connect()
set conn_ = Server.CreateObject("ADODB.Recordset")
strConnect = _T("Driver={MySQL ODBC 3.51 Driver};Server=localhost;"
"Database=MyDatabase;User=MyUserName;Password=MyPassword;Option=4;");
if Cstr(atr)="open" then
conn_.CursorLocation = adUseClient
conn_.Open sql, conn, 3, 2
set conn_.ActiveConnection = nothing
set declare_conn=conn_
else if Cstr(atr)="exec" then
conn.Open
conn.Execute sql
end if
end if
end function
function calldata(a,b,c,d)
dim conn_string, sql_string
if c<>"" and d<>"" then
sql_string="SELECT "&Cstr(a)&" FROM "&Cstr(b)&" WHERE "&Cstr(c)&" = '"&Cstr(d)&"'"
response.write(sql_string)
else
sql_string="SELECT "&Cstr(a)&" FROM "&Cstr(b)
response.write(sql_string)
end if
set conn_string = Server.CreateObject("ADODB.Recordset")
set conn_string = declare_conn(sql_string,"open")
set calldata = conn_string
end function
function savedata(a,b,c,d,e)
dim conn_string, sql_string, c_, d_, update_string
update_string = ""
if Cstr(a)="insert" then
sql_string="INSERT INTO "&Cstr(b)&" ("&Cstr(c)&") VALUES ("&Cstr(d)&")"
end if
response.write(sql_string)
'response.end
if Cstr(a)="update" then
c_ = split(c,", ",-1)
d_ = split(d,", ",-1)
response.write(c_)
response.end
if ubound(c_) = ubound(d_) then
do while not c_.eof
update_string=update_string&"("&Cstr(c_)&"="&Cstr(d_)&"),"
c_.MoveNext : d_.MoveNext
loop
else
%><script type="text/javascript">alert("save function error: array out of bound");</script> <%
end if
if Cstr(e)<>"" then
sql_string="UPDATE "&Cstr(b)&" SET "&update_string&" WHERE "&Cstr(e)
else
sql_string="UPDATE "&Cstr(b)&" SET "&update_string
end if
end if
'set conn_string = Server.CreateObject("ADODB.Recordset")
call declare_conn(sql_string,"exec")
end function
%>
错误实际上是什么意思?我在中创建到数据库 ADO 的连接
connect()
仍然,我可以毫无问题地运行
calldata()
编辑-dwerty_weird
S对不起吵架..
对于这个问题,我发现,我缺少“设置”:
set conn=Connect()
很抱歉给您带来麻烦...但是对于其他问题,我遇到了问题
call savedata("update","test_","name, id","'lalala', 222","bil=1")
它会得到错误:Microsoft VBScript runtime error '800a01a8' Object required /bkpi-msn/SPPro/function.asp, line 56 –</p>
谁能帮我?