How to resolve an error importing an Excel file into a SQL Server 2005 table: " is not a valid name. Make sure that it does not include invalid characters or punctuation?
I am creating an Access applicaton with an APD type file using Access as the front end and SQL Server 2005 as the back end database.
I use the following commands to import an Excel file into a SQL Server table.
Run time error '3125'
" is not a valid name. Make sure that it does not include invalid characters or punctuation
and that it is not too long.
Do you know how I can resolve this error?
Is the problem the input data?
I provided 2 input records in the attached Excel file.
the SQL Server table fields are defined as follows:
Field Name Data Type
-------------- -----------------
MailID nvarchar(255)
PartyID nvarchar(255)
Account nvarchar(255)
DocumentDate datetime
ScanDate datetime
DocumentType nvarchar(255)
Mailroom_Address1 nvarchar(255)
Mailroom_Address2 nvarchar(255)
Mailroom_Address3 nvarchar(255)
Mailroom_Address4 nvarchar(255)
Mailroom_Address5 nvarchar(255) TestFile.xls
Microsoft AccessMicrosoft SQL Server 2005
Last Comment
Randy Downs
8/22/2022 - Mon
Randy Downs
Sounds like it's not finding ImportedFile
ImportedFile = "U:\TestFile.XLS"
zimmer9
ASKER
I renamed the file to generate a file not found error.
Then I get:
Runtime error 3011
The Microsoft Jet database engine could not find the object 'U:\TestFile.XLS'.
Make sure the object exists and that you spell its name and the path name correctly.
Randy Downs
Try it using the literal file name. The variable doesn't seem to work
OK whatever drive you have access should work. Is that the U: drive?
zimmer9
ASKER
Yes, I have put the XLS file on the U: drive to which I have access.
Randy Downs
Apparently your code doesn't have access to the U: drive that's why I was looking for another. You could also try making everything lower case but it shouldn't matter if you are in a Windows environment.
See if you can run something like this from command line
excel.exe "U:\TestFile.XLS"
zimmer9
ASKER
Yes that works.
The program generates a run time error of 3125 when the file is there.
When the file is not there the program generates a runtime error of 3011.
ImportedFile = "U:\TestFile.XLS"