bsteo
bsteo

Reputation: 1779

ASP Vbscript runtime error: Object doesn't support this property or method

I have this piece of code that gives me this when executed:

Microsoft VBScript runtime error '800a01a8'

Object required: 'be01v-sat'

/CFIDE/csv.asp, line 90

The code is:

  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

What do I do wrong to get that error? Thank you!

Upvotes: 0

Views: 4801

Answers (1)

HeavenCore
HeavenCore

Reputation: 7683

Your usage of connection.open is invalid (looks like you have it confused with recordset.open) - try this:

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 

Upvotes: 1

Related Questions