I need to develop a program that stores the result of a select
in two variables and saves the data in a txt and shows by console the iteration resulting from the urls
I could already get it to print correctly in the console, they could indicate how to save the result of the iteration in a txt, that for each line a url is written with a line break.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string url1 = null;
SqlConnection con = new SqlConnection("server=SQL2014;database=ventas;integrated security = true");
string strSQL = "select Numero,Terreno "+
"FROM datos";
SqlCommand cmd = new SqlCommand(strSQL, con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string resultadoNumero = reader["Numero"].ToString();
string resultadoTerreno = reader["Terreno"].ToString();
url1 = "http://ReportServer/Pages/ReportViewer.aspx?/Pedidos" + resultadoNumero + resultadoTerreno;
Console.WriteLine(url1);
}
reader.Close();
con.Close();
Console.ReadLine();
}
}
}