MrTV
asked on
c# write database to text file
the code below output is
thisrowthisrowthisrowthisr
How can I change it to value from database i think must correct this statement
( System.IO.File.AppendAllTe
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Web;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string MyConString = "SERVER=localhost;" +
"DATABASE=registration;" +
"UID=root;" +
"PASSWORD='';";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = "select * from teera";
connection.Open();
Reader = command.ExecuteReader();
while (Reader.Read())
{
string thisrow = "";
for (int i = 0; i < Reader.FieldCount; i++)
thisrow += Reader.GetValue(i).ToString() + ",";
listBox1.Items.Add(thisrow);
System.IO.File.AppendAllText(@"C:\file.txt", "thisrow");
}
connection.Close();
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
System.IO.File.AppendAllTe