Solved

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

Posted on 2007-11-16
3
522 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

623 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