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
Fabio Silva
NA
19
834
Create individual files from mysql query results
May 7 2020 3:17 PM
hello, can anyone help me with this one?
I have made a mysql connection and results display, however i need to create a txt tile for each result, with the result as file name
Example:
mysql query returns "123123123", then file 123123123.txt woud be created.
here is my code as it stands
string
[] filePaths = Directory.GetFiles(@
"C:\Users\travi\Desktop\customers\Active"
);
foreach
(
string
filePath
in
filePaths)
File.Delete(filePath);
string
serverIp =
"localhost"
;
string
username =
"root"
;
string
password =
""
;
string
databaseName =
"teste"
;
string
dbConnectionString =
string
.Format(
"server={0};uid={1};pwd={2};database={3};"
, serverIp, username, password, databaseName);
string
query =
"SELECT ID FROM `wp_posts` WHERE `post_type` = 'shop_subscription' and post_status = 'wc-active'"
;
var conn =
new
MySql.Data.MySqlClient.MySqlConnection(dbConnectionString);
conn.Open();
var cmd =
new
MySql.Data.MySqlClient.MySqlCommand(query, conn);
var reader = cmd.ExecuteReader();
while
(reader.Read())
{
var subs = reader[
"ID"
];
// how to create individual files from each result
Reply
Answers (
1
)
How to bind custom icons to Html drop down for asp.net appli
csharp class adding object