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
Guest User
Tech Writer
77
13.9k
insert from csv file to database
Jul 26 2020 10:09 PM
Code below to open CSV file, how to store the data from csv file row by row into database mysql.
Please help me, im using visual studio 2019
sing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Runtime.Remoting.Channels;
using System.Data.SqlClient;
namespace TryingMyBest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void tmrLoop_Tick(object sender, EventArgs e)
{
tmrLoop.Enabled = false;
string dirName = @"C:\pub\ftp";
DirectoryInfo di = new DirectoryInfo(@"C:\pub\ftp");
FileInfo[] size = di.GetFiles();
MessageBox.Show("Directory ini ada file: ", di.Name);
DirectoryInfo info = new DirectoryInfo(@"C:\pub\ftp");
FileInfo[] filess = info.GetFiles().OrderByDescending(p => p.LastWriteTime).ToArray();
try
{
var files = Directory.EnumerateFiles(dirName);
foreach (string currFile in files)
{
MessageBox.Show(currFile);
MessageBox.Show("Size dia: " + currFile.Length.ToString());
Console.WriteLine();
}
foreach (FileInfo file in filess)
{
DateTime lastWriteTime = file.LastWriteTime;
MessageBox.Show("Time last Edit : " + lastWriteTime);
}
foreach (string path in Directory.EnumerateFiles(@"C:\pub\ftp", "*.csv"))
{
string[] lines = System.IO.File.ReadAllLines(path);
foreach (string line in lines)
{
Console.WriteLine(line);
string[] columns = line.Split(',');
foreach (string column in columns)
{
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
tmrLoop.Enabled = true;
}
private void btnOnStart_Click(object sender, EventArgs e)
{
tmrLoop.Enabled = true;
}
private void btnOnStop_Click(object sender, EventArgs e)
{
tmrLoop.Enabled = false;
}
}
}
Reply
Answers (
4
)
C# code to compare two pdf files so need to find the difference in two
Capture Image Crop and upload on another page in imagebox