Solved

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

Posted on 2007-11-16
3
505 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

707 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

11 Experts available now in Live!

Get 1:1 Help Now