<%--
   asp code Generated by Basic Processor
   Original Page Name: C:\gmTestBed\FMStocks\src\FMSWeb\ASP\_runsql.asp
--%>

<%@ Page language="VB" explicit="true" CodeBehind="_runsql.aspx.vb" Inherits="FMSWeb.__runsql" %>

<%
   HttpContext.Current.Response.Buffer = True
%>


<html>
<head>
<% _t_head1.Author_Markup() %>

	<title>Run SQL Command</title>
</head>
<body>
<% _t_begin1.Author_Markup() %>

<form method="post" action="_RunSQL.aspx">
<textarea rows="15" cols="40" id="SQLStatement" name="SQLStatement">
<%
   If (Not String.IsNullOrEmpty(HttpContext.Current.Request("SQLStatement"))) Then
      HttpContext.Current.Response.Write(HttpContext.Current.Request("SQLStatement"))
   Else
      HttpContext.Current.Response.Write("select * from stocks where company like '%.com%'")
   End If
%>
</textarea>
<input type="submit" value="GO">
<%
   If (Not String.IsNullOrEmpty(HttpContext.Current.Request("SQLStatement"))) Then
      dsn = db.ConnectionString()
      HttpContext.Current.Response.Write("<p>(Using DSN: " & dsn & ")</p>")
      conn.Open(dsn)
      rs = conn.Execute(HttpContext.Current.Request("SQLStatement"))
      If (rs Is Nothing) Then
         HttpContext.Current.Response.Write("<b>rs is nothing</b><br>")
      ElseIf (rs.State = 0) Then
         HttpContext.Current.Response.Write("<b>No results returned</b><br>")
      Else
         Do Until rs Is Nothing
            If (rs.State <> 0) Then
               HttpContext.Current.Response.Write("<table border=1>")
               'header
               HttpContext.Current.Response.Write("<tr>" & Constants.vbNewLine)
               Dim forTemp0 As gmRTL.DataLib.SqlClient.Field
               For Each forTemp0 in rs.Fields
                  f = forTemp0
                  HttpContext.Current.Response.Write(vbTab & "<td><strong>" & f.Name & "</strong></td>")
               Next
               HttpContext.Current.Response.Write("</tr>" & Constants.vbNewLine)
               'data
               Do Until rs.EOF
                  HttpContext.Current.Response.Write("<tr>" & Constants.vbNewLine)
                  Dim forTemp1 As gmRTL.DataLib.SqlClient.Field
                  For Each forTemp1 in rs.Fields
                     f = forTemp1
                     HttpContext.Current.Response.Write(vbTab & "<td>" & Convert.ToString(f.Value) & "</td>")
                  Next
                  HttpContext.Current.Response.Write("</tr>" & Constants.vbNewLine)
                  rs.MoveNext()
               Loop
               HttpContext.Current.Response.Write("</table><br>")
            End If
            rs = rs.NextRecordset( )
         Loop
      End If
   End If
%>
</form>
<% _t_end1.Author_Markup() %>

</body>
</html>
