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
scott oliver
NA
82
16.3k
Logic Error inserting values into sqlite from csv
Oct 11 2020 1:48 PM
Hello all. I am sure this has been asked before and I hope its an easy answer. I have some code that inserts information from a csv into sqlite. The csv has 9 colums but the table has 10 becuase I added a datetime column that needs to be added. I found some snips that seem to work, but I am not sure how to insert the date with it. I am trying not to have to break the csv into an array or something over complicated. below is the code and this is the web address of the instruction I found .
http://www.techbrothersit.com/2016/04/c-how-to-import-or-load-text-file-to.html
while
((line = SourceFile.ReadLine()) !=
null
)
{
//skip the header row
if
(counter > 0)
{
//prepare insert query
string
query =
"Insert into "
+ TableName +
" Values ('"
+ line.Replace(filedelimiter,
"','"
) +
"')"
;
//execute sqlcommand to insert record
SQLiteCommand myCommand =
new
SQLiteCommand(query, sqlConn);
myCommand.ExecuteNonQuery();
}
counter++;
}
Reply
Answers (
3
)
how to make long string short and add ...(3 dots ) at the end?
How to use panel in MVC like we use in asp.net