Unable to access destination table in SqlBulkCopy c#

officedog
officedog used Ask the Experts™
on
when attempting to use SqlBulkCopy with c#, I am getting the following error;

'Unable to access destination table'

I have googled various documents that refer to using the table/schema name are set as appropriate and have tried the following options;

Tablename
Schema.Tablename
[Schema].Tablename
[Schema].[Tablename]
Schema.[TableName]

All with the same results.

The user I am logging on with has limited rights, but does have Insert allowed for the table. Although it may be something to do with permissions, the message is not very helpful.

Any pointers as a little stuck.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Not sure if you even have the ability, but have you tried to manually insert something into the table?  Also, you might try fully qualifying it [database name].[schema name].[table name].  It's possible your connection string isn't getting you to the appropriate database.

Commented:
Did you try the below link? I hope it helps.

http://www.codeproject.com/KB/database/SqlBulkCopy.aspx
Software Engineer
Top Expert 2011
Commented:
The user you are logged in with will need both select and Insert rights

Author

Commented:
Will try adding the database identifier when I get back to the office, but I know for sure the connection string is correct as it is a global setting and the dev server currently only has that DB on it. The same connection string can is also able to run existing stored procedures.

Will also try adjusting the user permissions to allow select.

Will update when I have tried both.

Thanks

Author

Commented:
Added select rights to table and worked.

Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial