简体   繁体   English

ASP ADO连接Microsoft VBScript运行时错误'800a01a8'

[英]asp ADO connection Microsoft VBScript runtime error '800a01a8'

dear all pro programmer here, im totally new in here, and i might dont know how to correctly as a question here.. 亲爱的所有专业程序员,在这里是全新的,在这里我可能不知道如何正确地解决问题。

if i may ask for help, could u pls here here here... im having problem with simple asp with oop structure... 如果我可能会寻求帮助,您能在这里在这里吗...我对带有oop结构的简单asp有问题...

help me with function savedata pls. 用功能savedata pls帮助我。 when run, 运行时

call savedata("insert","test_","name, id","lalala, 222","User_ID=3")

got error : 出现错误:

INSERT INTO test_ (name, id) VALUES (lalala, 222) 插入test_(name,id)值(lalala,222)

... Microsoft VBScript runtime error '800a01a8' ... Microsoft VBScript运行时错误'800a01a8'

Object required: 'Conn' 所需对象:“ 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
%>

wht is tht error actually mean? 错误实际上是什么意思? i create a connection to database ADO in 我在数据库中创建到数据库ADO的连接

connect()

still, i can run without problem for 仍然,我可以毫无问题地运行

calldata()

editing-dwerty_weird editing-dwerty_weird


SOrry for the ruckus.. 对骚动很抱歉..

for this question, i find out, tht i missing "Set" for: 对于这个问题,我发现,我缺少以下内容的“设置”:

set conn=Connect() 

sorry for the trouble... but for other question, i having problem with 抱歉给您带来麻烦...但是对于其他问题,我遇到了问题

call savedata("update","test_","name, id","'lalala', 222","bil=1") 

it will get error : Microsoft VBScript runtime error '800a01a8' Object required /bkpi-msn/SPPro/function.asp, line 56 – 它将得到错误:Microsoft VBScript运行时错误'800a01a8'必需的对象/bkpi-msn/SPPro/function.asp,第56行–

can anyone help me? 谁能帮我?

You're missing single quotes in your data . 您在数据中缺少单引号 Value for name is a string and should be wrapped in single quotes. 名称的值是一个字符串,应该用单引号引起来。

You have already implemented this in calldata() that is why it is working fine. 您已经在calldata()中实现了它,这就是为什么它可以正常工作的原因。 Update the same for savedata too. 也为savedata更新相同的内容。

Note: This applies for all the string parameters and may apply in some other way (using #) for date / datetime parameters too. 注意:这适用于所有字符串参数,并且可能以其他方式(使用#)适用于日期/日期时间参数。

Please use this as a starting point and follow best-practices for development! 请以此为起点,并遵循最佳开发实践!

Hope this helps! 希望这可以帮助!

Vivek 维维克

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM