日期:2008-11-20  浏览次数:20439 次

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<html>
<head>

    <script language="VB" runat="server">

        Public Source As DataView
        Public DS As DataSet
        Public GetSchemaChecked, GetDataChecked As Boolean

        Sub Submit_Click(Sender As Object, E As EventArgs)

            If (Page.IsPostBack)

                Dim MyConnection As SqlConnection
                Dim MyCommand As SqlDataAdapter

                MyConnection = New SqlConnection(ConnectString.Value)
                MyCommand = New SqlDataAdapter(MyText.Value, MyConnection)

                DS = New DataSet()
                MyCommand.Fill(DS, "Table")

                Source = New DataView(DS.Tables(0))

                GetSchemaChecked = GetSchema.Checked
                GetDataChecked = GetData.Checked

                MyDataGrid.DataSource=Source
                MyDataGrid.DataBind()
            End If
         End Sub

    </script>

</head>
<body bgcolor="ffffcc">

    <h3><font face="Verdana">SQL to XML Generator</font></h3>

    <form runat="server">

        <table border=0 cellpadding=5 style="font:10pt verdana">
        <tr>
          <td colspan="2">
            <b>Connect String:</b><br>
            <input id="ConnectString" type="text" value="server=(local)\NetSDK;database=pubs;Trusted_Connection=yes" size="85" runat="server">
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <b>Query:</b><br>
            <input id="myText" type="text" value="select * from Authors" size="85" runat=&