0

I am attempting with no success to find a tutorial or a snippet to get me started on connecting to our database and downloading the contents using VBScript. I have the following code, which appears to work:

<%@ Language=VBScript  CODEPAGE=65001 %>
<% Option Explicit %>
<%response.Buffer=true%>
<!-- #include file="connect.asp" -->

After that, I found 1 code example, but when I try to run it I get a 500 error. Honestly, I am not even quite sure what some of this syntax does. Any help is appreciated in explaining this more.

<%
sql = "select *"
set resultset = connect.Execute(sql)
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="c:\exportDB.csv"
Set objFile = objFSO.CreateTextFile(outFile,True)

Dim row, first_field
while not resultset.EOF

row = ""
first_field = true

For Each field In resultset.Fields
    if (first_field = true) then
        row = field
        first_field = false
    else
        row = row & ";" & field
    end if
Next ' field

objFile.Write row & vbCrLf

resultset.MoveNext
wend
objFile.Close
%>

**UPDATED It appears our development server had features turned off which wasn't allowing me to run these code block and some others. With that now corrected, everything runs as it should.

RW Hammond
  • 113
  • 7
  • Thanks for your useful comment. For anyone else. Should my SQL statement not be select all? Should it be more specific? – RW Hammond Oct 23 '17 at 18:24
  • To help you get started learning out how to debug your own code: [Classic ASP on IIS7: refusing to send errors to browser on 500 Internal Server Error](https://stackoverflow.com/questions/1453791) – Igor Oct 23 '17 at 18:26
  • Thank you. I will give this a read over now. – RW Hammond Oct 23 '17 at 18:31

0 Answers0