SQL FOR XML Query results to Text via ASP.NET

Discussion in 'ASP .Net' started by Rob, Jan 7, 2004.

  1. Rob

    Rob Guest

    As a workaround to a problem I'm having with the results
    pane in Query Analyzer properly displaying a text field in
    a Latin1_General_Bin collation database, I've begun trying
    to use ASP.NET to return the results of the query in Text
    for use as a one time XML file build. The query is a FOR
    XML Explicit.

    So far, I've tried sending the results of the query via a
    stored procedure to a datagrid. However this cuts off
    much of the results due the column and row limitation in
    the grid. What I would simply like to do is some kind of
    response.write of the results of the query as text
    directly in the browser or in a very large text box rather
    than the datagrid. Then I can copy/paste to a text file
    and work with the results there.

    The code follows below:

    Private Sub Page_Load(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles MyBase.Load
    Dim cmd As System.Data.SqlClient.SqlCommand
    cmd = New System.Data.SqlClient.SqlCommand
    ("RobXML", Me.SqlConnection1)
    cmd.CommandType = CommandType.StoredProcedure
    Me.SqlConnection1.Open()
    Dim myDataReader As
    System.Data.Sqlclient.SqlDataReader = cmd.ExecuteReader
    (CommandBehavior.CloseConnection)
    DataGrid1.DataSource = myDataReader
    DataGrid1.DataBind()
    myDataReader.Close()
    Me.SqlConnection1.Close()
    End Sub

    Private Sub DataGrid1_SelectedIndexChanged(ByVal
    sender As System.Object, ByVal e As System.EventArgs)

    End Sub
    End Class
     
    Rob, Jan 7, 2004
    #1
    1. Advertisements

  2. Rob

    Rob Guest

    I tried the code below from the help files to read through
    the datareader and print the results, however, I get
    a "timeout" error. Is there a way to use Response.Write
    instead? The query results are large. Thank you in
    advance.

    If myDataReader.HasRows Then
    Do While myDataReader.Read()
    Console.WriteLine(vbTab & "{0}" & vbTab
    & "{1}", myDataReader.GetInt32(0), myDataReader.GetString
    (1))
    Loop
    Else
    Console.WriteLine("No rows returned.")
    End If

    >-----Original Message-----
    >As a workaround to a problem I'm having with the results
    >pane in Query Analyzer properly displaying a text field

    in
    >a Latin1_General_Bin collation database, I've begun

    trying
    >to use ASP.NET to return the results of the query in Text
    >for use as a one time XML file build. The query is a FOR
    >XML Explicit.
    >
    >So far, I've tried sending the results of the query via a
    >stored procedure to a datagrid. However this cuts off
    >much of the results due the column and row limitation in
    >the grid. What I would simply like to do is some kind of
    >response.write of the results of the query as text
    >directly in the browser or in a very large text box

    rather
    >than the datagrid. Then I can copy/paste to a text file
    >and work with the results there.
    >
    >The code follows below:
    >
    > Private Sub Page_Load(ByVal sender As System.Object,
    >ByVal e As System.EventArgs) Handles MyBase.Load
    > Dim cmd As System.Data.SqlClient.SqlCommand
    > cmd = New System.Data.SqlClient.SqlCommand
    >("RobXML", Me.SqlConnection1)
    > cmd.CommandType = CommandType.StoredProcedure
    > Me.SqlConnection1.Open()
    > Dim myDataReader As
    >System.Data.Sqlclient.SqlDataReader = cmd.ExecuteReader
    >(CommandBehavior.CloseConnection)
    > DataGrid1.DataSource = myDataReader
    > DataGrid1.DataBind()
    > myDataReader.Close()
    > Me.SqlConnection1.Close()
    > End Sub
    >
    > Private Sub DataGrid1_SelectedIndexChanged(ByVal
    >sender As System.Object, ByVal e As System.EventArgs)
    >
    > End Sub
    >End Class
    >
    >
    >.
    >
     
    Rob, Jan 7, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gerry Hickman
    Replies:
    2
    Views:
    1,708
    Gerry Hickman
    Dec 14, 2005
  2. Anonymous
    Replies:
    0
    Views:
    1,879
    Anonymous
    Oct 13, 2005
  3. ABC
    Replies:
    1
    Views:
    1,417
    Jeremy S.
    May 12, 2006
  4. drlexkingdome
    Replies:
    1
    Views:
    896
    Mark McIntyre
    Dec 19, 2004
  5. Chris McFarling

    Export SQL query results to text file

    Chris McFarling, Sep 16, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    8,958
    George
    Sep 17, 2008
  6. Bill McCarthy
    Replies:
    3
    Views:
    3,892
    Alexey Smirnov
    Jan 23, 2009
  7. Eric Nelson
    Replies:
    5
    Views:
    1,741
    Alexey Smirnov
    Feb 4, 2009
  8. Erik Wasser
    Replies:
    5
    Views:
    843
    Peter J. Holzer
    Mar 5, 2006
Loading...