G
gavC
Guest
Hi all,
Im having a problem using the DoCmd.TransferText method to insert a comma separated text file into Access.
Everything seems to work fine except Access is removing any leading zeros from a Text field. For example, I have an account code of "000002" in the text file (does not have double quotes in text file), however, this becomes "2" in the database after the Import. AAAAAGGGHHH!!
I've tried numerous things to fix this but nothing seems to work.
I dont want to have to create an Import Specification but want to use the default settings if possible. Could there be something wrong with the way I am creating the table. I'm using T-SQL datatypes (e.g - varchar, money, etc...). These all seem to transfer to Access dataTypes successfully though....
Here is the code that I'm using (in C#):
****************************************
Access.ApplicationClass accApp = new Access.ApplicationClass();
accApp.OpenCurrentDatabase("D:\\testDB.mdb", false);
accApp.DoCmd.TransferText(Access.AcTextTransferType.acImportDelim, "", "dividend", "D:\\Test.txt",true,"",850);
accApp.CloseCurrentDatabase();
****************************************
Any help would be greatly appreciated as Im starting to get a real headache with this!!
Cheers,
gavC
Im having a problem using the DoCmd.TransferText method to insert a comma separated text file into Access.
Everything seems to work fine except Access is removing any leading zeros from a Text field. For example, I have an account code of "000002" in the text file (does not have double quotes in text file), however, this becomes "2" in the database after the Import. AAAAAGGGHHH!!
I've tried numerous things to fix this but nothing seems to work.
I dont want to have to create an Import Specification but want to use the default settings if possible. Could there be something wrong with the way I am creating the table. I'm using T-SQL datatypes (e.g - varchar, money, etc...). These all seem to transfer to Access dataTypes successfully though....
Here is the code that I'm using (in C#):
****************************************
Access.ApplicationClass accApp = new Access.ApplicationClass();
accApp.OpenCurrentDatabase("D:\\testDB.mdb", false);
accApp.DoCmd.TransferText(Access.AcTextTransferType.acImportDelim, "", "dividend", "D:\\Test.txt",true,"",850);
accApp.CloseCurrentDatabase();
****************************************
Any help would be greatly appreciated as Im starting to get a real headache with this!!
Cheers,
gavC