开发者

godaddy sql executor with .net

开发者 https://www.devze.com 2023-01-09 20:43 出处:网络
Most of you might have known already that godaddy does\'nt have any plugins or components to directly connect to the database hosted on their servers to run a sql statement. Godaddy wants the develope

Most of you might have known already that godaddy does'nt have any plugins or components to directly connect to the database hosted on their servers to run a sql statement. Godaddy wants the developers to login into their sql management interface and run the queries, which is a time consuming process and more over I personally feel that interface is not robust with limited session time and so. Please correct me if I am wrong.

So, I wanted to create a little .net screen with a text area and a button control to execute the sql statements typed in the text area. I am planning to implement this using data reader object. But my question is, how to read the field names(not values) for heading purpose from the reader?开发者_如何学编程

Or Let me know if there is any better implementation to get my work done.

Thank you,

Krishna.


C#

private void PrintColumnNames(DataSet dataSet)
{
    // For each DataTable, print the ColumnName.
    foreach(DataTable table in dataSet.Tables)
    {
        foreach(DataColumn column in table.Columns)
        {
            Console.WriteLine(column.ColumnName);
        }
    }
}

VB

Private Sub PrintColumnNames(dataSet As DataSet)
    Dim table As DataTable
    Dim column As DataColumn 

    For Each table in dataSet.Tables
        For Each column in table.Columns
        Console.WriteLine(column.ColumnName)
        Next
    Next
End Sub


Why not just bind to an editable GridView?


Another way would be to create a .sql file using a stream writer and execute the script using sqlcmd or osql.

0

精彩评论

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