Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 529
  • Last Modified:

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?
0
kb85505
Asked:
kb85505
  • 2
1 Solution
 
grant300Commented:
Sybase has a Bulk Interface API that is part of Open Client (ct-lib).  It is the interface that the BCP program uses to bulk data into and out of the database quickly.  It is many times faster than using a record-by-record interface like ODBC or worse, .NET.

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
0
 
kb85505Author Commented:
Do you have any good links that might show how to use the Perl option?  That sounds like a possible choice.
0
 
grant300Commented:
There is a whole pot of information on the web about DBD::SYBASE and SybPerl.  The Michel Peppler stuff is usually pretty good.

The Perl Doc has a section on DBD::Sybase and the Bulk capabilities at:
http://search.cpan.org/~mewp/DBD-Sybase-1.08/Sybase.pm#Experimental_Bulk-Load_Functionality

After that, I would fall back on good old google search.

Regards,
Bill
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now