<HTML>
<HEAD><TITLE>Interactive SQL</TITLE></HEAD>
<BODY>

<%

  ' This is an ODBC connection string. Change this as 
  ' appropriate for your system's configuration.
  '
  strConn = "DSN=BJEPSON_MSSQL;UID=bjepson;PWD=secret"
 
  ' After the users hit submit, look for an SQL string.
  '
  strSQL = Request("SQL")
  If strSQL <> "" Then
 
    ' Create an empty result set.
    '
    Set rsResult = Server.CreateObject("ADODB.Recordset")
 
    ' Send the SQL to the server. If there were any results,
    ' display them in a table.
    '
    rsResult.Open strSQL, strConn
 
    ' It was a command (insert, create, update), not a query.
    '
    If rsResult.state = adStateClosed Then
      Response.Write("Command completed successfully.<BR>")
 
    ' It was a query that had no results.
    '
    ElseIf rsResult.EOF Then
      Response.Write("Query returned no results.<BR>")
 
    ' It was a query with results.
    '
    Else
 
      %> <TABLE BORDER> <%
 
      For Each field in rsResult.Fields
        %> <TH>  <%=field.name %> </TH> <%
      Next
 
      Do Until rsResult.EOF
        %> <TR> <%
        For Each field in rsResult.Fields
          %> <TD>  <%=field.value %> </TD> <%
        Next
        %> </TR> <%
        rsResult.MoveNext
      Loop
 
      %> </TABLE> <%
 
    End If

  End If  

%>

<FORM>
  <TEXTAREA NAME="SQL" ROWS="7" COLS="45"></TEXTAREA>
  <INPUT TYPE="SUBMIT" VALUE="Execute SQL">
</FORM>

</BODY><HTML>
<HEAD><TITLE>Interactive SQL</TITLE></HEAD>
<BODY>

<%

  ' This is an ODBC connection string. Change this as 
  ' appropriate for your system's configuration.
    '
  strConn = "DSN=BJEPSON_MSSQL;UID=bjepson;PWD=secret"
 
  ' After the users hit submit, look for an SQL string.
  '
  strSQL = Request("SQL")
  If strSQL <> "" Then
 
    ' Create an empty result set.
    '
    Set rsResult = Server.CreateObject("ADODB.Recordset")
 
    ' Send the SQL to the server. If there were any results,
    ' display them in a table.
    '
    rsResult.Open strSQL, strConn
 
    ' It was a command (insert, create, update), not a query.
    '
    If rsResult.state = adStateClosed Then
      Response.Write("Command completed successfully.<BR>")
 
    ' It was a query that had no results.
    '
    ElseIf rsResult.EOF Then
      Response.Write("Query returned no results.<BR>")
 
    ' It was a query with results.
    '
    Else
 
      %> <TABLE BORDER> <%
 
      For Each field in rsResult.Fields
        %> <TH>  <%=field.name %> </TH> <%
      Next
 
      Do Until rsResult.EOF
        %> <TR> <%
        For Each field in rsResult.Fields
          %> <TD>  <%=field.value %> </TD> <%
        Next
        %> </TR> <%
        rsResult.MoveNext
      Loop
 
      %> </TABLE> <%
 
    End If

  End If  

%>

<FORM>
  <TEXTAREA NAME="SQL" ROWS="7" COLS="45"></TEXTAREA>
  <INPUT TYPE="SUBMIT" VALUE="Execute SQL">
</FORM>

</BODY>v