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
narasiman rao
NA
519
766.9k
how to retrieve file name to be stored in variable
Aug 28 2016 10:07 AM
My code as follows
int count = 0;
string connectionstring = "Server=(local);initial catalog=Test;Trusted_Connection=True";
SqlConnection sqlConnection = new SqlConnection(connectionstring);
SqlCommand cmd = new SqlCommand();
SqlDataReader reader;
DataSet ds = new DataSet();
cmd.CommandText = "select * from Empdetails";
cmd.CommandText += " where shifttype = @par ";
cmd.Parameters.Add("@par", SqlDbType.Int).Value = j;
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection;
sqlConnection.Open();
reader = cmd.ExecuteReader();
if (reader.HasRows)
{
string filePath = @"C:\Users\God\Desktop\DataDump\" + j + "Excel.xls";
System.IO.StreamWriter sw_In = new System.IO.StreamWriter(filePath);
while (reader.Read())
{
if (count == 0)
{
for (int i = 0; i < reader.FieldCount; i++)
{
sw_In.AutoFlush = true;
sw_In.Write(reader.GetName(i) + "\t");
}
sw_In.Write("\n");
count = 1;
}
for (int i = 0; i < reader.FieldCount; i++)
{
sw_In.AutoFlush = true;
sw_In.Write(reader[i].ToString() + "\t");
}
sw_In.Write("\n");
}
}
reader.Close();
sqlConnection.Close();
when i run the above code two excel file is downloaded in desktop under C Folder as follows
1Excel
2Excel
i want the above Excel file name to retrieved and displayed.
for that how can i do to retireve the excel file name and to be displayed
Reply
Answers (
3
)
Mail is working but i want send two excel file to eachperson
Using query get date for today date and tomorrow date