C
CuriousCoder15
Guest
Hi,
I have a stored procedure that creates an XML file using 'FOR XML PATH'. I want to write the xml to a file in c#,
My function to call the SP is:
List<string> Xml = new List<string>( );
SqlCommand Command = new SqlCommand("callXML", new SqlConnection( ConnectionString) ) ;
Command.CommandType = CommandType.StoredProcedure ;
Command.Parameters.AddWithValue( "@Date" , Date ) ;
Command.Parameters.AddWithValue( "@Event" , Event ) ;
Command.Parameters.AddWithValue( "@Contestant" , Cont ) ;
Command.Connection.Open( );
SqlDataReader myReader = _Command.ExecuteReader(CommandBehavior.CloseConnection);
if ( myReader.HasRows )
{
while ( myReader.Read( ) )
{
Xml.Add( "something!!" );
}
myReader.Close( );
}
Command.Connection.Close( );
When I hover over myReader.HasRows I can see in results view/non-public members/ values:
[0] and if I look here I can see the entire file.
I want to add the file to a string List How can I accomplish this?
Do I need a different type of way to read the file because it throws an exception as soon as it hits :
while(myReder.Read())
CuriousCoder
Continue reading...
I have a stored procedure that creates an XML file using 'FOR XML PATH'. I want to write the xml to a file in c#,
My function to call the SP is:
List<string> Xml = new List<string>( );
SqlCommand Command = new SqlCommand("callXML", new SqlConnection( ConnectionString) ) ;
Command.CommandType = CommandType.StoredProcedure ;
Command.Parameters.AddWithValue( "@Date" , Date ) ;
Command.Parameters.AddWithValue( "@Event" , Event ) ;
Command.Parameters.AddWithValue( "@Contestant" , Cont ) ;
Command.Connection.Open( );
SqlDataReader myReader = _Command.ExecuteReader(CommandBehavior.CloseConnection);
if ( myReader.HasRows )
{
while ( myReader.Read( ) )
{
Xml.Add( "something!!" );
}
myReader.Close( );
}
Command.Connection.Close( );
When I hover over myReader.HasRows I can see in results view/non-public members/ values:
[0] and if I look here I can see the entire file.
I want to add the file to a string List How can I accomplish this?
Do I need a different type of way to read the file because it throws an exception as soon as it hits :
while(myReder.Read())
CuriousCoder
Continue reading...