Solved

How do I run a Sybase 12.51 BCP from a .NET application

Posted on 2007-11-16
3
509 Views
Last Modified: 2013-11-25
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
Comment
Question by:kb85505
  • 2
3 Comments
 
LVL 19

Expert Comment

by:grant300
ID: 20300107
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
 

Author Comment

by:kb85505
ID: 20315852
Do you have any good links that might show how to use the Perl option?  That sounds like a possible choice.
0
 
LVL 19

Accepted Solution

by:
grant300 earned 250 total points
ID: 20316086
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now