Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > SQL FOR XML Query results to Text via ASP.NET

Reply
Thread Tools

SQL FOR XML Query results to Text via ASP.NET

 
 
Rob
Guest
Posts: n/a
 
      01-07-2004
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


 
Reply With Quote
 
 
 
 
Rob
Guest
Posts: n/a
 
      01-07-2004
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
>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET won't retrieve query results that depend on union query Eric Nelson ASP .Net 5 02-04-2009 10:51 PM
Export SQL query results to text file Chris McFarling ASP .Net 3 09-17-2008 04:16 AM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
Build dynamic sql query for JSTL <sql:query> Anonymous Java 0 10-13-2005 10:01 PM
simple(?) xml/xsl problem with xml from sql query dSchwartz XML 1 03-06-2004 02:06 AM



Advertisments