can any one to told me how to fix my code because I am trying to get information for text file and insert it to database Access. right now I am trying to get the form text file using ADO.net I get the information but I want to see it on console windows
Hey, I just downloaded your code to see where you are coming from. Thoughts. Have you thought about using the File System Class? That way, you can bypass the Database/ADO.NET altogether, and store everything in a text-file on the server. You would need to delimiate the file for storage, then retrieve it later, and even add to the text-file. Basically a flat-text database. Check out the File System built into .NET to help you out.
Mainly, StreamWriter and StreamReader. Along with a few other objects.
Well, if you are importing a text file into access, frankly the best tool could be access. No ADO.NET required.
If you need to go through ADO.NET for some reason, check out the FileHelpers library -- it is great at munging text files.
thank all right now I use FileHelpers library and I follow the example in how to use it. but I counter one problem the console app can't convert Datatime for the birthday
and this is error message
"Error Converting ' BirthDate (mm/dd/yyyy)' to type: 'DateTime'. There are more chars than in the format string: 'dd/MM/yyyy'
public class Employee
public string FirstName;
public string LastName;
public string Address1;
public string City;
public string PostalCode;
public string PhoneNumber;
public string SocialInsuranceNumber;
public DateTime BirthDate;
static void Main(string args)
FileHelperEngine eng = new FileHelperEngine(typeof(Employee));
Employee emp = eng.ReadFile("Employees.txt") as Employee;
foreach (Employee empl in emp)
Console.WriteLine(empl.FirstName + "-" + empl.BirthDate.ToString("M/dd/yy"));
Ran into this one before, they use DateTime.ParseExact() which is very finnicky. Best bet is to use a custom field converter that wraps DateTime.Parse(). Note that isn't very performant if you have alot of records, like a few million.