我有这段代码在执行时给我这个:
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 :(得分: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