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

时间:2020-12-19 02:06:13

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...

如果我可以寻求帮助,请你来这里这里...我有一个问题与简单的asp与oop结构...

help me with function savedata pls. when run,

帮助我使用函数saveata pls。跑步时

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

got error :

得到错误:

INSERT INTO test_ (name, id) VALUES (lalala, 222)

INSERT INTO test_(name,id)VALUES(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

编辑 - dwerty_weird


SOrry for the ruckus..

为了骚动而烦恼..

for this question, i find out, tht i missing "Set" for:

对于这个问题,我发现,我错过了“Set”:

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?

谁能帮我?

1 个解决方案

#1


0  

You're missing single quotes in your data. Value for name is a string and should be wrapped in single quotes.

您缺少数据中的单引号。 name的值是一个字符串,应该用单引号括起来。

You have already implemented this in calldata() that is why it is working fine. Update the same for savedata too.

你已经在calldata()中实现了这个,这就是为什么它工作正常。也为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

维韦克

#1


0  

You're missing single quotes in your data. Value for name is a string and should be wrapped in single quotes.

您缺少数据中的单引号。 name的值是一个字符串,应该用单引号括起来。

You have already implemented this in calldata() that is why it is working fine. Update the same for savedata too.

你已经在calldata()中实现了这个,这就是为什么它工作正常。也为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

维韦克