bcp是命令行程序,其实你可以不用sqlcommand去通过xp_cmdshell调用的。
直接在vc里调用这个exe程序就可以了。

解决方案 »

  1.   

    这个应该是VC的问题:
    http://topic.csdn.net/t/20030516/21/1794983.html
      

  2.   

    BCP是在DOS命令下用,VC怎么调DOS命令,搜索一下,一大堆.
      

  3.   

    #include <stdafx.h>
    int WinMain()
    {
      // TODO: Place code here.
    WinExec("C:\\Program Files\\Microsoft SQL Server\\90\\Tools\\Binn\\bcp test.dbo.ta out c:\\test.txt -c -S.\\sqlexpress -Usa -Pbd5178",1); return 0;
    }/*
    OK请按任意键继续. . .
    开始复制...已复制 1 行。
    网络数据包大小(字节): 4096
    总时钟时间(毫秒)     : 1      平均值: (每秒 1000.00 行。)
    */
      

  4.   

    WinExec("bcp UFN.dbo.accountsetions in c:\\test.txt -c -S(local) -T -t, -F2",1);顺利执行了,但是没导入数据,为什么?
      

  5.   


    WinExec("C:\\Program Files\\Microsoft SQL Server\\80\\Tools\\Binn bcp UFN.dbo.accountsetions in c:\\test.txt -c -S(local) -T -t, -F2",1);这样也不行..
      

  6.   

    binn\\bcp
    路径怎么样,依具你机子上bcp文件所在的位置。\\是转义\来的,你作c++的,不用我说多吧。当然,你的c++代码编译后所在的位置假设为 d:\myProject\bin 那 么可以在命令行下切到此目录 ,然后执行 path=bcp所在目录。
    执行时直接winexec("bcp....") 而不用敲路径。
      

  7.   

    厄,解决了.... WinExec("C:\\Program Files\\Microsoft SQL Server\\80\\Tools\\Binn\\bcp UFN.dbo.accountsetions in c:\\test.txt -c -S(local) -T -t, -F2",1); 嘿嘿,谢了,给分。