简体   繁体   中英

Incorrect syntax near ',' AseBulkCopy

I have a code to implement a bulk copy from MSSQL SERVER to SYBASE (12.5) using ASE client, but at the WriteToServer() function i always get the error " Incorrect syntax near ','". NOTE: i have even changed the DestinationTableName to a table that does not exist, but i still get the same error. my Code below

using (AseConnection theCons = new AseConnection(connstring))
{          
    try
    {
        if (theCons.State != ConnectionState.Open)
        {
            theCons.Open();
        }

        AseBulkCopy objbulk = new AseBulkCopy(theCons);

        objbulk.DestinationTableName = "dbo.testBulk";

        try
        {
            objbulk.WriteToServer(dt); //dt is my source DataTable from MSSQL SERVER
        }
        catch (Exception exception)
        {

        }
    }
    catch (Exception exception)
    {

    }
    finally
    {
        if (theCons != null)
        {
            if (theCons.State != ConnectionState.Closed)
                theCons.Close();
        }
    }
}

This error generated, when provider cannot find target table and use empty table name to query metadata for bulk copy (yep, checking operation results is not for real developers...).

In your case problem lies in "dbo.testBulk" line. Eg your table named TestBulk (Title-case) or not in dbo schema.

Hint how to debug it. ASE client use following code to get table schema:

cn.GetSchema("columns", new object[] {tableName, ownerName, databaseName });

so you need to put your dbo and testBulk components here and see if it will return columns metadata.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM