views:

47

answers:

3

Hello Guys,

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.

A: 

Why not just bind to an editable GridView?

Josh Stodola
I believe we need to set the "HeaderText" property to the grid view. But in my case I will be doing dynamic sql statements.
Krishna
@Krishna Wrong, it automatically generates columns by default.
Josh Stodola
@Josh Thank you very much, I will give a try.
Krishna
A: 

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

Ash Burlaczenko
+1  A: 

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
ksogor