TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Naidu AMMAN
NA
37
35.1k
reports
Sep 26 2013 5:08 AM
please how to store the data by using select query and how can this data save in text file please reply me as soon as possible .
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 System.IO;
using DataAccessLayer;
namespace prjtims
{
public partial class frmtotremits : Form
{
private StreamWriter filewriter;
public frmtotremits()
{
InitializeComponent();
// btnok.Enabled = false;
}
private void btnok_Click(object sender, EventArgs e)
{
string str_output;
IDBManager dbManager = new DBManager(DataProvider.MySql);
dbManager.ConnectionString = "Server=localhost;Database=microfx;Uid=root;Pwd=root";
try
{
DataSet etm_ticket_data_private_aug_2013;
dbManager.Open();
etm_ticket_data_private_aug_2013 = dbManager.ExecuteDataSet(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");
// while (dbManager.DataReader.Read())
// MessageBox.Show("recorded");
// dbManager.ExecuteDataSet(CommandType.Text, "");
str_output = "ANDRA PRADESH STATE ROAD TRANSPORT CORPORATION" + "\n";
str_output = "BANDLAGUDA" + "\n";
str_output = "TOTAL REMITTANCE REPORT" + "\n";
str_output = "WAYBILL No" + "\n";
str_output = "IN DATE" + "\n";
str_output = "SERVICE CODE " + "\n";
str_output = "SERVICE DETAILS" + "\n";
str_output = "SERVICE TYPE" + "\n";
str_output = "VEHICLE No" + "\n";
str_output = "OPR KMS" + "\n";
str_output = "TRIPS OPR" + "\n";
str_output = "CONDUCTOR No" + "\n";
str_output = "CONDUCTOR NAME" + "\n";
str_output = "DRIVER No" + "\n";
str_output = "DRIVER NAME" + "\n";
str_output = "DRIVER 2 NO" + "\n";
str_output = "DRIVER 2 NAME" + "\n";
str_output = "TIM No" + "\n";
str_output = "DEPOT TIM No" + "\n";
cmb_srvc_no.Text = "";
date_tm_pckr_frm_dte.Text = "";
dt_tm_pkr_to_date.Text = "";
DialogResult result;
string fileName;
using (SaveFileDialog fileChooser = new SaveFileDialog())
{
fileChooser.CheckFileExists = false;
result = fileChooser.ShowDialog();
fileName = fileChooser.FileName;
}
if (result == DialogResult.OK)
{
if (fileName == string.Empty)
{
MessageBox.Show("Invalid File Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
FileStream flstrm = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
MessageBox.Show("Error opening file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
string[] values = new string[3];
values[0] = cmb_srvc_no.Text;
values[1] = date_tm_pckr_frm_dte.Text;
values[2] = dt_tm_pkr_to_date.Text;
// you can get file name from `ShowDialog`,
//assume that file name is "filename.txt" then
System.IO.File.WriteAllLines("E:\\oracle.txt", values);
dbManager.Close();
}
}
}
catch (Exception ex)
{
//Usual Code
}
finally
{
dbManager.Dispose();
MessageBox.Show("Successfully saved");
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Reply
Answers (
0
)
Url Rewriting
C# Programming Question