Naidu AMMAN

Naidu AMMAN

  • NA
  • 37
  • 35.1k

how to save the database in textfile by using c# windows

Sep 25 2013 3:53 AM
hi this gyana. please how to call from data base in C# by using select query and how to save this data in text file please reply me.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
  1. using System.Linq;
using System.Text;
using System.Windows.Forms;

using DataAccessLayer;


namespace prjtims
{
    public partial class frmtotremits : Form
    {
        public frmtotremits()
        {
            InitializeComponent();
        }

        private void btnok_Click(object sender, EventArgs e)
        {


            IDBManager dbManager = new DBManager(DataProvider.MySql);
            dbManager.ConnectionString = "Server=local instance MYSQL56;Database=microfx

Uid=root;Pwd=root";

            try
            {
                dbManager.Open();

                dbManager.ExecuteReader(CommandType.Text, "SELECT count(*),etd_ticket_type,sum(etd_child_fare),sum(etd_adult_fare),etd_service_code FROM microfx.etm_ticket_data_private_aug_2013 where ETD_LAST_UPD_DATE between '2013-07-30 18:30:00' and '2013-07-31 18:30:00' group by etd_ticket_type,etd_service_code order by etd_service_code;");

                cmb_srvc_no.Text = "";
                date_tm_pckr_frm_dte.Text = "";
                dt_tm_pkr_to_date.Text = "";




                string file_name = "E:\\oracle.txt";
                System.IO.StringReader objReader;
                objReader = new System.IO.StringReader(file_name);
                //objReader.ReadLine(file_name);
                objReader.Close();


               
                dbManager.Close();                       
           }
            catch (Exception ex)
            {
                //Usual Code
            }
            finally
            {
                dbManager.Dispose();
                MessageBox.Show("Sucessfully opened");
            }
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

       
    }
}

Answers (2)