kb85505
asked on
How do I run a Sybase 12.51 BCP from a .NET application
I think I may already know the answer to this, but I was hoping someone may have a way to execute a BCP command from inside a .NET application.
We are currently using VS 2005 and connecting to Sybase 12.51 running on a Unix server. We have the Sybase PC Client installed on our workstations and we're using the ADO.NET provider to connect to Sybase.
We have a need to move some fairly large csv and flat files to the server. I was hoping there was sometining similar to the MS SQLServer ODBC API that would allow BCP execution from inside the application without the need to shell out. Is there anything loike this available, or is there anything in the native Sybase providers that we could use?
We are currently using VS 2005 and connecting to Sybase 12.51 running on a Unix server. We have the Sybase PC Client installed on our workstations and we're using the ADO.NET provider to connect to Sybase.
We have a need to move some fairly large csv and flat files to the server. I was hoping there was sometining similar to the MS SQLServer ODBC API that would allow BCP execution from inside the application without the need to shell out. Is there anything loike this available, or is there anything in the native Sybase providers that we could use?
ASKER
Do you have any good links that might show how to use the Perl option? That sounds like a possible choice.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The Bulk Interface is part of the Open Client/Server Common Libraries and is documented in the associated reference manual at:
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ocs_12.5.1.comlib/html/comlib/title.htm&toc=/com.sybase.help.ocs_12.5.1/toc.xml
MS added a proprietary, non-transportable feature to its ODBC drivers when it included support for the Bulk Copy API. I don't believe anyone else supports a bulk interface through ODBC so you are going to be stuck writing to the Sybase ct-lib bulk API directly. It is not hard to do; it is just different than ODBC.
Another option you might want to consider is writing a load module in Perl. the DBD::Sybase module support the bulk api so you could write a program that does everything you need including solid error handling and shell that out. It has advantages over shelling to the BCP program in that you get program control and clean error handling written the way you need it. I have gotten several of my clients to use Sybperl/DBD::Sybase for installers and utilities rather than shelling scripts to ISQL because it gives so much more control.
Regards,
Bill