2012-03-08 71 views
0

我有這段代碼執行時,讓我:ASP VBScript運行時錯誤:對象不支持此屬性或方法

Microsoft VBScript runtime error '800a01a8' 

Object required: 'be01v-sat' 

/CFIDE/csv.asp, line 90 

的代碼是:

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then 
    dim server,username,password,database,table 
    server = Request.Form("server") 
    username = Request.Form("username") 
    password = Request.Form("password") 
    database = Request.Form("database") 
    table = Request.Form("table") 
    dim RS1 
    set RS1 = Server.CreateObject("ADODB.Connection") 
     RS1.Open "SELECT * FROM " & table & "", "server=" & server & ";UID=" & username & ";PWD=" & password & ";database=" & database & ";Provider=SQLOLEDB", 0, 1 

    Response.ContentType = "text/csv" 

    Response.AddHeader "Content-Disposition", "attachment;filename=export.csv" 

    Write_CSV_From_Recordset RS1 
    End If 

做什麼我錯了,得到那個錯誤?謝謝!

+0

'be01v-SAT' 是通過POST發送SQL Server名稱。 – bsteo 2012-03-08 09:39:10

回答

1

你的connection.open使用是無效的(看起來你有它混淆recordset.open) - 試試這個:

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then 
    dim server,username,password,database,table 
    strServer = Request.Form("server") 
    username = Request.Form("username") 
    password = Request.Form("password") 
    database = Request.Form("database") 
    table = Request.Form("table") 
    dim conn, rs 
    set conn = Server.CreateObject("ADODB.Connection") 
    set rs = Server.CreateObject("ADODB.Recordset") 
    conn.Open "DRIVER={SQL Server};SERVER=" & strServer & ";DATABASE=" & database & ";UID=" & username & ";PWD=" & password, username, password 
    set rs = conn.execute("SELECT * FROM " & table) 

    Response.ContentType = "text/csv" 
    Response.AddHeader "Content-Disposition", "attachment;filename=export.csv" 

    Write_CSV_From_Recordset rs 
End If 
+0

哎呀,似乎我真的混淆:)謝謝!這樣可行! – bsteo 2012-03-08 10:55:14

+0

Microsoft VBScript運行時錯誤 '800a01a8' 所需的 對象: 'be01v-SAT' /CFIDE/csv.asp,行90 一樣...我應該張貼所有的代碼? – bsteo 2012-03-08 11:00:08

+0

是的,請確保你的帖子90 – HeavenCore 2012-03-08 11:02:29

相關問題