开发者

output data to text file in asp. markup code

开发者 https://www.devze.com 2023-01-18 06:09 出处:网络
I downloaded some sample code which includes a database query within the markup code. It makes a query to the database and displays the results of the web form and I would like to divert the output to

I downloaded some sample code which includes a database query within the markup code. It makes a query to the database and displays the results of the web form and I would like to divert the output to a text file and I am not sure how to do this? Can this be done from here or would it just be easier to code it in the source and make a new connection to the database?

Sample code:

 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringIP %>"
        DeleteCommand="DELETE FROM [ip-to-country] WHERE [ID] = ?" InsertCommand="INSERT INTO [ip-to-country] ([ID], [BeginingIP], [EndingIP], [TwoCountryCode], [ThreeCountryCode], [CountryName]) VALUES (?, ?, ?, ?, ?, ?)"
        ProviderName="<%$ ConnectionStrings:ConnectionStringIP.ProviderName %>" SelectCommand="SELECT * FROM [ip-to-country] WHERE (([BeginingIP] &lt;= ?) AND ([EndingIP] &gt;= ?))"
        UpdateCommand="UPDATE [ip-to-country] SET [BeginingIP] = ?, [EndingIP] = ?, [TwoCountryCode] = ?, [ThreeCountryCode] = ?, [CountryName] = ? WHERE [ID] = ?">

        <SelectParameters>
            <asp:ControlParameter ControlID="txtIPNumber" DefaultValue="" Name="BeginingIP" PropertyName="Text"
                Type="Double" />
            <asp:ControlParameter ControlID="txtIPNumber" DefaultValue="" Name="EndingIP" PropertyName="Text"
                Type="Double" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="BeginingIP" Type="Double" />
            <asp:Parameter Name="EndingIP" Type="Double" />
            <asp:Parameter Name="TwoCountryCode" Type="String" />
            <asp:Parameter Name="ThreeCountryCode" Type="String" />
            <asp:Parameter Name="CountryName" Type="String" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="ID" Type="Int32" />
            <asp:Parameter Name="BeginingIP开发者_如何学Python" Type="Double" />
            <asp:Parameter Name="EndingIP" Type="Double" />
            <asp:Parameter Name="TwoCountryCode" Type="String" />
            <asp:Parameter Name="ThreeCountryCode" Type="String" />
            <asp:Parameter Name="CountryName" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    <br />
    IP Address :
    <asp:TextBox ID="txtIPAddress" runat="server" Wrap="False"></asp:TextBox>
    <br />
    IP Number :
    <asp:TextBox ID="txtIPNumber" runat="server" AutoPostBack="True" ReadOnly="True"
        Wrap="False"></asp:TextBox>
    <br />
    <br />


You would be better off doing this in the code behind, do the database call to a dataset or entities etc, do whatever it is you want to do with the data and then use the same data objects as the source for a datagrid or repeater, or however you wish to display this data.

0

精彩评论

暂无评论...
验证码 换一张
取 消